def setUserTel(): telvalue = request.args.get('telvalue') user = User() user.username = uname print(telvalue, user) result = userMgService.setUserTel(user, telvalue) if result: return redirect('/usermain')
def setUserPwd(): pwdvalue = request.args.get('pwdvalue') user = User() user.username = uname # print(pwdvalue,user) result = userMgService.setUserPwd(user, pwdvalue) if result: return redirect('/usermain')
def sign_up(email, name, password): qry = User.query(getattr(User, 'email') == email) if qry.fetch(1): raise UserAlreadyExistsException(email) new_user = User(email=email, name=name, password=password) new_user.put() print(type(new_user.email)) return email
def usermg(name): # print(name) global uname uname = name user = User() user.username = uname result = userMgService.getUserByName(user) # print(result) return render_template('user/index.html', result=result)
def alterPwd(): userName = session.get("userName") userPwd = request.form['password'] user = User() user.userName = userName user.userPwd = userPwd result = userDao.updateUser(user) if result: return render_template('photo1.html') else: return render_template('alterPwd.html')
def validusername(): username = request.form['username'] # print(username) user = User() user.username = username result = userService.getAllUserByName(user) # print(result) # print(type(result)) if str(result) == "1": return '1' else: return '0'
def loginValidate(): username = request.form['username'] userpwd = request.form['userpwd'] user = User() user.username = username user.userpwd = userpwd result = userService.getUserByNamePwd(user) if result: return render_template('index.html', result=result) else: msg = "用户名或密码错误!" return render_template('login.html', msg=msg)
def new_game(): user = User(app.db, request.environ.get('REMOTE_ADDR')) if user.is_playing: redirect('/play/' + user.session_name) difficult = request.forms.get('difficult') if difficult is None: last_games = user.get_last_games() return template('views/new_game.html', {'last_games': last_games}) else: # create new game session = user.start_game(app.game, difficult) redirect('/play/' + session)
def register(): # 注册 if request.method == 'POST': req_json = request.get_data() rec_obj = json.loads(req_json) user = User() user.username = rec_obj['username'] user.nick = rec_obj['nick'] user.age = rec_obj['age'] user.gender = rec_obj['gender'] user.city = rec_obj['city'] user.password = str( hashlib.md5(rec_obj['password'].encode()).hexdigest()) try: mysql = Mysql() sess = mysql._DBSession() if sess.query( User.id).filter(User.username == user.username).count() > 0: return jsonify({"code": 1000, "msg": "用户已存在"}) sess.add(user) sess.commit() sess.close() result = jsonify({"code": 0, "msg": "注册成功"}) return result except Exception as e: # print(str(e)) return jsonify({"code": 2000, "msg": "error"})
def Register_judge(): userName = request.form['username'] userPwd = request.form['password'] reUserPwd = request.form['reuserpwd'] regiest = re.compile( r'^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$') if userPwd == reUserPwd and userName != "": if regiest.search(userPwd): user = User() user.userName = userName userPwd = md5(userPwd) user.userPwd = userPwd result = userDAO.createUser(user) return result
def register(): userName = request.form['userName'] userPwd = request.form['userPwd'] if userName != "" and userPwd != "": user = User() user.userName = userName user.userPwd = userPwd result = userDAO.createUser(user) if result: return render_template('index.html', message="注册成功,请登录", code=500) # 第一参数是其他的URL,message是带过去的数据 if result: return render_template('register.html', message="注册失败", code=500) # 第一参数是其他的URL,message是带过去的数据 pass
def decorated_view(*args, **kwargs): login_disabled = os.getenv('LOGIN_DISABLED') == 'True' user = User(current_user.get_id()) if (login_disabled or user.get_role() == Role.Writer): log.debug( f'User "{current_user.get_id()}" is authorised and has write permissions' ) return func(*args, **kwargs) else: log.debug( f'User "{current_user.get_id()}" does not have write permissions' ) abort(403, "User is unauthorised to perform this action...")
def callback(): log.debug( 'Callback URL has been invoked after the user has been authenticated' ) token_url, token_headers, token_body = oauth_client.prepare_token_request( token_url="https://github.com/login/oauth/access_token", authorization_response=request.url, client_secret=client_secret) token_response = requests.post(token_url, headers=token_headers, data=token_body) oauth_client.parse_request_body_response( token_response.content.decode()) # Add token to the request uri, body or authorization header. user_info_request_url, user_info_request_headers, user_info_request_body = oauth_client.add_token( uri='https://api.github.com/user', ) user_info_response = requests.get(user_info_request_url, data=user_info_request_body, headers=user_info_request_headers) github_username = user_info_response.json()['login'] user = User(github_username) login_success = login_user(user) if login_success: log.debug(f'Successful logon for {github_username}') return redirect(url_for('index')) else: log.warning(f'Failed logon for {github_username}') return "Unauthorised", 403
def test_send_email_object(): user = User('genchevskiy', 'test') email = Email(user.email, 'Test Subject 2', 'Hello') main_page = Login_Page().open().login_as(user) main_page.send_new_email().send_message_with(email) main_page._success_sent_link().should_be(visible) main_page.openInbox().emails_list._get(1)._subject().should_be(visible, 10).should_have(text(email.subject))
def Login_judge(): userName = request.form['username'] userPwd = request.form['password'] if userName != "" and userPwd != "": user = User() user.userName = userName user.userPwd = md5(userPwd) result = userDAO.getUserByUserNameAndPwd(user) if result != None: print(result) session['userName'] = userName session['roleid'] = result[0] print(session['userName']) return result else: return result
def get_user_by_id(id): model = MysqlConnModel.get_instance() user = model.find("user", {"id": id}, multi=False) if len(user) < 1: return None else: return User(user[0])
def registerS(): username = request.form['username'] userpwd = request.form['userpwd'] usertel = request.form['tel'] user = User() user.username = username user.userpwd = userpwd user.usertel = usertel result = userService.getInsertUser(user) if result: feedback = "注册成功!" return render_template('login.html', feedback=feedback) else: feedback = "注册失败!" return render_template('register.html', feedback=feedback) pass
def callback(): log.debug('User has hit login callback') token_request_url, token_request_headers, token_request_body = oauth_client.prepare_token_request( token_url="https://github.com/login/oauth/access_token", authorization_response=request.url, state=state, client_secret=client_secret) token_response = requests.post(token_request_url, headers=token_request_headers, data=token_request_body) oauth_client.parse_request_body_response( token_response.content.decode(), state=state) user_info_request_url, user_info_request_headers, user_info_request_body = oauth_client.add_token( uri='https://api.github.com/user', ) user_info_response = requests.get(user_info_request_url, data=user_info_request_body, headers=user_info_request_headers) github_username = user_info_response.json()['login'] log.debug(f'Logging in user with username "{escape(github_username)}"') user = User(github_username) login_success = login_user(user) if login_success: log.debug(f'User login for "{escape(github_username)}" successful') return redirect(url_for('index')) else: log.error( f'User login for "{escape(github_username)}" unsuccessful') return "Unauthorised", 403
def test_send_email(self): user = User('genchevskiy', 'test') main_page = Login_Page().open().login_as(user) main_page.send_new_email().send_message("Test Subject", "Hello!", user.email) main_page._success_sent_link().should_be(visible) main_page.openInbox()._email_list().should_have(size_at_least(1))
def test_positive_login(self): user = User('genchevskiy', 'test') main_page = Login_Page().open().login_as(user) main_page._account_button().should_be(visible, 10) self.assertIn( "Аккаунт Google: Savva Genchevskiy \n({})".format(user.email), main_page._account_button().get_attribute("title"))
async def create_entity(self, data: dict, **kwargs) -> tuple: # crypt code if data.get(User.password.name): data[User.password.name] = User.p_encrypt(data[User.password.name]) result, errors = await super().create_entity(data, **kwargs) return result, errors
def form_entity(self): entities = [] for i, j in enumerate(self.__data): if self.__flag == 0: # get base station entities entities.append(BS(i, [float(j[0]), float(j[1])], 200)) elif self.__flag == 1: # get user entities entities.append(User(i, [float(j[0]), float(j[1])])) return entities
def run(self) -> str: first_name = input("Enter first name:") last_name = input("Enter last name:") username = input("Enter username:"******"Enter password:"******"You are successfully registered as: {user.first_name} {user.last_name} [{user.username}]."
def get_users_by_ids(id_list): model = MysqlConnModel.get_instance() user_list = model.find("user", {"id": id_list}, multi=True) user_obj_list = [] for user_record in user_list: user_obj = User(user_record) user_obj_list.append(user_obj) return user_obj_list
def test_positive_login(self): user = User('genchevskiy', 'test') main_page = Login_Page().open().login_as(user) main_page._account_button().should_be(visible, 10) assert_that( main_page._account_button().get_attribute('title').encode('utf-8'), contains_string('Аккаунт Google: Savva Genchevskiy'))
def editpassuser(sess): userName = request.form['newusername'] userPwd = request.form['oldpassword'] userPwd1 = request.form['newpassword'] edit = re.compile( r'^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$') userlist = userDAO.getUserinfo(sess) if userName != None and userName != '': userPwd = md5(userPwd) if userlist[0][0] == userPwd: if edit.search(userPwd1): user = User() user.userName = userName userPwd1 = md5(userPwd1) user.userPwd = userPwd1 result = userDAO.editUserById(user, sess) return result else: userPwd = md5(userPwd) if userlist[0][0] == userPwd: if edit.search(userPwd1): user = User() userPwd1 = md5(userPwd1) user.userPwd = userPwd1 result = userDAO.editUserById(user, sess) return result
def load_from_excel(file): excel_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "%s.xlsx" % file) wb = load_workbook(filename=excel_file, read_only=True) ws = wb["Sheet1"] users = [] for row in ws.iter_rows(min_row=1, min_col=1, max_row=2, max_col=2): users.append(User(username=row[0].value, password=row[1].value)) return users
def create_user(): user = User() user.FirstName = 'Admin' user.LastName = 'System' user.Username = '******' user.Password = hashlib.md5("admin").hexdigest() user.Email = '*****@*****.**' return user
def login(): userName = request.form['username'] userPwd = request.form['password'] if userName != "" and userPwd != "": user = User() user.userName = userName user.userPwd = userPwd result = userDao.getUserByUserNameAndPwd(user) if result: session['userName'] = user.userName print(session['userName']) print(session.get("userName")) users = userDao.getAllUsers() return render_template('photo1.html', user=user, users=users) else: message = "用户名或者密码错误" return render_template('login.html', message=message, code=500)
def login(): #return render_template('main.html') userName = request.form['userName'] userPwd = request.form['userPwd'] if userName != "" and userPwd != "": user = User() user.userName = userName user.userPwd = userPwd result = userDAO.getUserByUserNameAndPwd(user) session['userName'] = userName # session 存放在服务器上,在超时时间之前一直存在 if result: users = userDAO.getAllUsers() return render_template('main.html', users=users) else: message = "用户名或密码不正确" return render_template('index2.html', message=message, code=500) # 第一参数是其他的URL,message是带过去的数据 pass
def initData(self): user1 = User() user1.name = 'Johnson' user1.password = User.hash_password('123') user1.put() user2 = User() user2.name = 'john' user2.password = User.hash_password('321') user2.put()
def testGetUser(self): print str(User.get_user('Johnson', '123'))