Python sign up
22 Python code examples are found related to "
sign up".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: main.py From python-examples with MIT License | 6 votes |
def sign_up(): # [] A set of characters "[a-m]" # \ Signals a special sequence (can also be used to escape special characters) "\d" # . Any character (except newline character) "he..o" # ^ Starts with "^hello" # $ Ends with "world$" # * Zero or more occurrences "aix*" # + One or more occurrences "aix+" # {} Exactly the specified number of occurrences "al{2}" # | Either or "falls|stays" # () Capture and group regpass = "^[A-Z][\w(!@#$%^&*_+?)+]{8,}$" if not (re.search(regpass,reg_password.get())): m.configure(text='''->Spaces and empty sets are not allowed. \n ->First character should be a capital letter. \n ->Password must be greater than 8 character and must contain a special character.''') elif (reg_password != reg_cnfpassword): m.configure(text='Password and Confirm Password must match') else : m.configure(text='') # --- main ---
Example 2
Source File: user.py From python-sdk with GNU Lesser General Public License v3.0 | 6 votes |
def sign_up(self, username=None, password=None): """ 创建一个新用户。新创建的 User 对象,应该使用此方法来将数据保存至服务器,而不是使用 save 方法。 用户对象上必须包含 username 和 password 两个字段 """ if username: self.set("username", username) if password: self.set("password", password) username = self.get("username") if not username: raise TypeError("invalid username: {0}".format(username)) password = self.get("password") if not password: raise TypeError("invalid password") self.save(make_current=True)
Example 3
Source File: Robot.py From AmazonRobot with MIT License | 6 votes |
def sign_up(self, sign_up_form, sign_up_url = r'https://www.amazon.com/ap/register?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26ref_%3Dnav_custrec_newcust'): """sign up with randomly generate user Args: sign_up_form (dict): some infomation required to sign up: name, e-mail and password sign_up_url (str, optional): url to sign up, custom url can jumps to the target url after signing up """ # generate and change mac address # mac = generate_mac_address() #change_mac_address(mac) try: self.driver.get(sign_up_url) for k,v in sign_up_form.items(): inputElement = self.driver.find_element_by_name(k) inputElement.send_keys(v) time.sleep(5) inputElement.submit() user_info = sign_up_form['email']+'#'+sign_up_form['password']+'#'+mac self.store_registered_user(user_info) except Exception, e: print 'Error while signing up\n%s'%e.message self.exit_driver() sys.exit(0)
Example 4
Source File: views.py From authy2fa-flask with MIT License | 6 votes |
def sign_up(): """Powers the new user form""" form = SignUpForm(request.form) if form.validate_on_submit(): try: user = create_user(form) session['user_id'] = user.id return redirect(url_for('main.account')) except AuthyApiException as e: form.errors['Authy API'] = [ 'There was an error creating the Authy user', e.msg ] return render_template('signup.html', form=form)
Example 5
Source File: cfs_client.py From tencentcloud-cli with Apache License 2.0 | 5 votes |
def doSignUpCfsService(argv, arglist): g_param = parse_global_arg(argv) if "help" in argv: show_help("SignUpCfsService", g_param[OptionsDefine.Version]) return param = { } cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey]) http_profile = HttpProfile( reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]), reqMethod="POST", endpoint=g_param[OptionsDefine.Endpoint] ) profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256") mod = CLIENT_MAP[g_param[OptionsDefine.Version]] client = mod.CfsClient(cred, g_param[OptionsDefine.Region], profile) client._sdkVersion += ("_CLI_" + __version__) models = MODELS_MAP[g_param[OptionsDefine.Version]] model = models.SignUpCfsServiceRequest() model.from_json_string(json.dumps(param)) rsp = client.SignUpCfsService(model) result = rsp.to_json_string() jsonobj = None try: jsonobj = json.loads(result) except TypeError as e: jsonobj = json.loads(result.decode('utf-8')) # python3.3 FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
Example 6
Source File: main.py From susi_api_wrapper with Apache License 2.0 | 5 votes |
def sign_up(email, password): params = { 'signup': email, 'password': password } sign_up_url = api_endpoint + '/aaa/signup.json' api_response = requests.get(sign_up_url, params) parsed_dict = api_response.json() return get_sign_up_response(parsed_dict)
Example 7
Source File: response_parser.py From susi_api_wrapper with Apache License 2.0 | 5 votes |
def get_sign_up_response(parsed_dict): identity_json = parsed_dict['session']['identity'] identity = Identity(identity_json) session = Session(identity) return SignUpResponse(parsed_dict, session)
Example 8
Source File: Robot.py From AmazonRobot with MIT License | 5 votes |
def generate_sign_up_user(self, random_password = False): """ramdomly generate a user to sign up Args: random_password (bool, optional): use uniform password or specific password """ # user name conn = get_connection(DB=3) user_name = conn.srandmember('user_name', 1)[0] # mail box prefix = string.digits+string.lowercase postfix = ['@126.com', '@163.com', '@sina.com', '@gmail.com', '@139.com', '@foxmail.com'] prefix_len = random.randint(5,12) mail = '' for i in xrange(prefix_len): mail += random.choice(prefix) mail_box = mail+random.choice(postfix) # password if random_password: candidates = string.digits+string.letters+'!@$%&*+-_' passwd = '' for i in xrange(random.randint(7,17)): passwd += random.choice(candidates) else: passwd = 'ScutAmazon1234$' sign_up_form = {'customerName':user_name, 'email':mail_box, 'password':passwd, 'passwordCheck':passwd} return sign_up_form
Example 9
Source File: bcrypt_hash.py From listen-now with MIT License | 5 votes |
def Sign_Up_Encrypt(self, user_id, passwd="Wechat_Mini_Program"): global re_dict Token_Crypto = None if passwd == "Wechat_Mini_Program": # 注册请求来自微信则不验证密码信息 if list(self.user_db.find({"user_id":user_id})) == []: # 还没注册 self.user_db.insert({"user_id":user_id, "encrypt_passwd":"Wechat_Mini_Program"}) re_dict["code"] = ReturnStatus.USER_WECHAT_SIGN re_dict["status"] = "Success" re_dict["user_id"] = user_id[::-1] create_token = AES_Crypt_Cookies() Token_Crypto = create_token.Creat_Token(timevalue, user_id[::-1], ip, ua) else: user_id = user_id[::-1] if self.r.get(user_id) == None: # 如果redis查询结果为空,则证明账户可以注册 salt = ''.join(random.sample(string.ascii_letters + string.digits, 8)) passwd = (passwd + salt[:4])[::-1] + salt[4:] passwd = bytes(passwd, encoding = "utf8") hashed = bcrypt.hashpw(passwd, bcrypt.gensalt(10)) # 对password做10轮的加密,获得了加密之后的字符串hashed,\ # 生成形如:$2a$10$aoiufioadsifuaisodfuiaosdifasdf if list(self.user_db.find({"user_id":user_id})) == [] and self.r.set(user_id, salt) == True: self.user_db.insert({"user_id":user_id, "encrypt_passwd":hashed}) re_dict["code"] = ReturnStatus.USER_SIGN_SUCCESS re_dict["status"] = "Success" re_dict["user_id"] = user_id[::-1] create_token = AES_Crypt_Cookies() Token_Crypto = create_token.Creat_Token(timevalue, user_id[::-1], ip, ua) re_dict['token_message'] = Token_Crypto # 返回token参数数据 else: re_dict["code"] = ReturnStatus.USER_SIGN_ERROR re_dict["status"] = "Failed" re_dict["user_id"] = user_id[::-1] return re_dict
Example 10
Source File: auth.py From Archery with Apache License 2.0 | 5 votes |
def sign_up(request): sign_up_enabled = SysConfig().get('sign_up_enabled', False) if not sign_up_enabled: result = {'status': 1, 'msg': '注册未启用,请联系管理员开启', 'data': None} return HttpResponse(json.dumps(result), content_type='application/json') username = request.POST.get('username') password = request.POST.get('password') password2 = request.POST.get('password2') display = request.POST.get('display') email = request.POST.get('email') result = {'status': 0, 'msg': 'ok', 'data': None} if not (username and password): result['status'] = 1 result['msg'] = '用户名和密码不能为空' elif len(Users.objects.filter(username=username)) > 0: result['status'] = 1 result['msg'] = '用户名已存在' elif password != password2: result['status'] = 1 result['msg'] = '两次输入密码不一致' elif not display: result['status'] = 1 result['msg'] = '请填写中文名' else: # 验证密码 try: validate_password(password) Users.objects.create_user( username=username, password=password, display=display, email=email, is_active=1) except ValidationError as msg: result['status'] = 1 result['msg'] = str(msg) return HttpResponse(json.dumps(result), content_type='application/json') # 退出登录
Example 11
Source File: cfs_client.py From tencentcloud-sdk-python with Apache License 2.0 | 5 votes |
def SignUpCfsService(self, request): """本接口(SignUpCfsService)用于开通CFS服务。 :param request: Request instance for SignUpCfsService. :type request: :class:`tencentcloud.cfs.v20190719.models.SignUpCfsServiceRequest` :rtype: :class:`tencentcloud.cfs.v20190719.models.SignUpCfsServiceResponse` """ try: params = request._serialize() body = self.call("SignUpCfsService", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.SignUpCfsServiceResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
Example 12
Source File: views.py From django-example-channels with MIT License | 5 votes |
def sign_up(request): form = UserCreationForm() if request.method == 'POST': form = UserCreationForm(data=request.POST) if form.is_valid(): form.save() return redirect(reverse('example:log_in')) else: print(form.errors) return render(request, 'example/sign_up.html', {'form': form})
Example 13
Source File: _onenormest.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def sign_round_up(X): """ This should do the right thing for both real and complex matrices. From Higham and Tisseur: "Everything in this section remains valid for complex matrices provided that sign(A) is redefined as the matrix (aij / |aij|) (and sign(0) = 1) transposes are replaced by conjugate transposes." """ Y = X.copy() Y[Y == 0] = 1 Y /= np.abs(Y) return Y
Example 14
Source File: user.py From Reseed-backend with GNU Affero General Public License v3.0 | 5 votes |
def sign_up(): username = request.form['username'] password = request.form['password'] site = request.form.get('site', 'tjupt') user_id = request.form['id'] user_passkey = request.form['passkey'] # Check site id in our database if not mysql.check_site_id_registered(site, user_id): return jsonify({'success': False, 'msg': 'This ID has been used in Site: {}.'.format(site)}), 403 # check if user is valid in site msg = check_id_passkey(site, user_id, user_passkey) if msg: return jsonify({'success': False, 'msg': msg}), 403 # Create user if their name is not dupe if not mysql.get_user(username): salt = bcrypt.gensalt() passhash = bcrypt.hashpw(password.encode('utf-8'), salt) mysql.signup(username, passhash.decode('utf-8'), site, user_id) return jsonify({'success': True, 'msg': 'Registration success!'}), 201 else: return jsonify({'success': False, 'msg': 'Username existed!'}), 403
Example 15
Source File: bots.py From Dallinger with MIT License | 5 votes |
def sign_up(self): """Accept HIT, give consent and start experiment. This uses Selenium to click through buttons on the ad, consent, and instruction pages. """ try: self.driver.get(self.URL) logger.info("Loaded ad page.") begin = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.CLASS_NAME, "btn-primary")) ) begin.click() logger.info("Clicked begin experiment button.") WebDriverWait(self.driver, 10).until(lambda d: len(d.window_handles) == 2) self.driver.switch_to_window(self.driver.window_handles[-1]) self.driver.set_window_size(1024, 768) logger.info("Switched to experiment popup.") consent = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, "consent")) ) consent.click() logger.info("Clicked consent button.") participate = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.CLASS_NAME, "btn-success")) ) participate.click() logger.info("Clicked start button.") return True except TimeoutException: logger.error("Error during experiment sign up.") return False
Example 16
Source File: helper.py From tensorflow-u-net with GNU General Public License v3.0 | 5 votes |
def sign_up(generator): """ Signs up a generator with the current pipeline. """ global pipeline if pipeline is not None: pipeline.sign_up(generator)
Example 17
Source File: auth.py From Telethon with MIT License | 4 votes |
def sign_up( self: 'TelegramClient', code: typing.Union[str, int], first_name: str, last_name: str = '', *, phone: str = None, phone_code_hash: str = None) -> 'types.User': """ Signs up to Telegram as a new user account. Use this if you don't have an account yet. You must call `send_code_request` first. **By using this method you're agreeing to Telegram's Terms of Service. This is required and your account will be banned otherwise.** See https://telegram.org/tos and https://core.telegram.org/api/terms. Arguments code (`str` | `int`): The code sent by Telegram first_name (`str`): The first name to be used by the new account. last_name (`str`, optional) Optional last name. phone (`str` | `int`, optional): The phone to sign up. This will be the last phone used by default (you normally don't need to set this). phone_code_hash (`str`, optional): The hash returned by `send_code_request`. This can be left as `None` to use the last hash known for the phone to be used. Returns The new created :tl:`User`. Example .. code-block:: python phone = '+34 123 123 123' await client.send_code_request(phone) code = input('enter code: ') await client.sign_up(code, first_name='Anna', last_name='Banana') """ me = await self.get_me() if me: return me if self._tos and self._tos.text: if self.parse_mode: t = self.parse_mode.unparse(self._tos.text, self._tos.entities) else: t = self._tos.text sys.stderr.write("{}\n".format(t)) sys.stderr.flush() phone, phone_code_hash = \ self._parse_phone_and_hash(phone, phone_code_hash) result = await self(functions.auth.SignUpRequest( phone_number=phone, phone_code_hash=phone_code_hash, first_name=first_name, last_name=last_name )) if self._tos: await self( functions.help.AcceptTermsOfServiceRequest(self._tos.id)) return self._on_login(result.user)
Example 18
Source File: user_auth.py From radremedy with Mozilla Public License 2.0 | 4 votes |
def sign_up(): """ Handles user signup. Associated template: create-account.html Associated form: SignUpForm """ # Kick the current user back to the index # if they're already logged in if current_user.is_authenticated: return index_redirect() # Get active populations and set up the form population_choices = active_populations() form = SignUpForm( request.form, group_active_populations(population_choices)) if request.method == 'GET': return render_template('create-account.html', form=form) else: if form.validate_on_submit(): # Create the user. u = User(form.username.data, form.email.data, form.password.data) # If we have a display name, use that - otherwise, # default to the username. if form.display_name.data and not form.display_name.data.isspace(): u.display_name = form.display_name.data else: u.display_name = form.username.data # Set up populations pop_ids = set(form.populations.data) for new_pop_id in pop_ids: # Find it in our population choices and add it in new_pop = next( (p for p in population_choices if p.id == new_pop_id), None) if new_pop: u.populations.append(new_pop) # Generate an activation code u.email_code = str(uuid4()) u.email_activated = False # Save the user and send a confirmation email. db.session.add(u) db.session.commit() send_confirm_account(u) # Display the success page return render_template('create-account-success.html') else: flash_errors(form) return render_template('create-account.html', form=form), 400
Example 19
Source File: views.py From server with MIT License | 4 votes |
def sign_up(request): """ Adds a new user to database Note: client's email is stored as username in database (NO explicit difference in email and username) :param request: contains first name, last name, email Id (username) and password :return: 400 if incorrect parameters are sent or email ID already exists :return: 201 successful """ firstname = request.POST.get('firstname', None) lastname = request.POST.get('lastname', None) username = parseaddr(request.POST.get('email', None))[1].lower() password = request.POST.get('password', None) if not firstname or not lastname or not username or not password: # incorrect request received error_message = "Missing parameters in request. Send firstname, lastname, email, password" return Response(error_message, status=status.HTTP_400_BAD_REQUEST) if not validate_email(username): error_message = "Invalid email Id" return Response(error_message, status=status.HTTP_400_BAD_REQUEST) if not validate_password(password): error_message = "Invalid Password" return Response(error_message, status=status.HTTP_400_BAD_REQUEST) try: User.objects.get(username=username) error_message = "Email Id already exists" return Response(error_message, status=status.HTTP_400_BAD_REQUEST) except User.DoesNotExist: success_message = "Successfully registered." user = User.objects.create_user(username, password=password) user.first_name = firstname user.last_name = lastname user.is_superuser = False user.is_staff = False user.save() # Attempt sending email to_list = [user.username] fullname = "{} {}".format(firstname, lastname) mail_subject = WELCOME_MAIL_SUBJECT.format(firstname) mail_content = WELCOME_MAIL_CONTENT.format(fullname) if not is_send_email(to_list, mail_subject, mail_content): success_message += " Unable to send a welcome email to user" except Exception as e: error_message = str(e) return Response(error_message, status=status.HTTP_400_BAD_REQUEST) success_message = "Successfully registered" return Response(success_message, status=status.HTTP_201_CREATED)