def user_blogs(user_id=None): if user_id is not None: user = User.get_by_id(user_id) else: user = User.get_by_email(session['email']) blogs = user.get_blogs() return render_template('user_blogs.html', blogs=blogs, email=user.email)
def save(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] user = User(username, password) user.save() return
def register_user(): email = request.form['email'] password = request.form['password'] User.register(email, password) return render_template("profile.html", email=session['email'])
def submit_quiz(): if request.get_json() is None: return jsonify({"result": "error", "field":"", "message": "Not valid model!"}), 200 quiz = Quiz.factory_form_json(request.get_json()) if quiz.get_points() is "": return jsonify({"result": "error", "field":"points", "message": "Points cannot be empty"}), 200 if not quiz.is_valid_model(): return jsonify({"result": "error", "field":"", "message": "Not valid model!"}), 200 if len(quiz.get_title()) == 0: return jsonify({"result": "error", "field": "title", "message": "Title cannot be empty!"}), 200 if quiz.get_points() < 0: return jsonify({"result": "error", "field":"points", "message": "Points cannot be less then 0!"}), 200 quiz_real = Quiz.get_by_id(uuid.UUID(quiz._id)) passed = False if quiz_real.mark_subbmitted_quiz(quiz): passed = True try: QuizProfile.get_by_composite_id(uuid.UUID(quiz._id),session['email']) return jsonify({"result": "ok", "field": "title", "message": "", "relocateTo": "/quiz_profile/"+str(quiz_real.get_id()) }), 200 except NoSuchQuizProfileExistException as e: new_quiz_profile = QuizProfile(uuid.UUID(quiz._id),session['email'],datetime.now(),0,passed) new_quiz_profile.save_to_db() User.update_user_points(session['email'],"virtual",quiz_real.get_points()) return jsonify({"result": "ok", "field": "title", "message": "", "relocateTo": "/quiz_profile/"+str(quiz_real.get_id())}), 200
def admin_edit_profile_page(user): universities = University.get_uni_list() profile = User.find_by_email(user) mypermissions = User.get_user_permissions(session['email']) permissions = [permission_level for permission_level in Database.find(Permissions.COLLECTION, {})] return render_template('edit-profile.html', user=user, universities=universities, profile=profile, permissions=permissions, mypermissions=mypermissions)
def test_save_simple_user_to_db(self): email = "*****@*****.**" user = User(email, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") user.permissions = Permissions.default().name user.save_to_db() self.assertIsNotNone(User.find_by_email(email)) Database.remove("users", {"email": email})
def login(): email = request.form['email'] password = request.form['password'] if User.login_valid(email, password): User.login(email) else: session['email'] = None return render_template("profile.html", email=session['email'])
def home_function(): email = request.form['email'] password = request.form['password'] if User.login_valid(email,password): User.login_valid(email,password) else: session['email'] = None return render_template('homepage.html',user=session['email'])
def login_user(): email = request.form['email'] password = request.form['password'] if User.login_valid(email, password): print('user verified') User.login(email) else: session['email'] = None print('session email', session['email']) return render_template('profile.html', email=session['email'])
def edit_profile(): if User.check_login(session['email'], request.form['password']): user = User.find_by_email(session['email']) user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'], university=request.form['university'], level=request.form['level'], country=request.form['country'], school=request.form['college'], subject=request.form['course'], year=request.form['yearofstudy']) user.save_to_db() return make_response(view_profile()) else: return render_template('user-profile.html', message="Incorrect Password")
def login_user(): email = request.form['email'] password = request.form['password'] if User.login_valid(email, password): User.login(email) else: session['email'] = None return render_template('login.html', failed_login=True) # check if variable check_login is passed, other wise do not display error message return render_template("profile.html", email=session['email'])
def admin_update_user_profile(): if User.check_login(session['email'], request.form['password']): user = User.find_by_email(request.form['email']) user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'], university=request.form['university'], level=request.form['level'], country=request.form['country'], school=request.form['college'], subject=request.form['course'], year=request.form['yearofstudy'], permissions=request.form['permissions']) user.save_to_db() return redirect("/admin/view-profile/" + request.form['email']) else: return render_template('user-profile.html', message="Incorrect Password")
def login_user(): email=request.form['email'] password=request.form['password'] if User.login_valid(email,password): User.login(email) else: session['email']=None print('Wrong Details') return render_template("login.html",email=session['email']) return render_template("choice.html",email=session['email'])
def login_userapp(): email=request.form['email'] password=request.form['password'] if User.login_valid(email,password): User.login(email) print('Correct Details') else: session['email']=None print('Wrong Details') return jsonify({"status":"success"})
def update_attended(user, event_id): id_ = uuid.UUID(event_id) event = Event.get_by_id(id_) category = event.get_event_type() points = event.get_points() if EventRegister.get_user_attended(user, event_id): EventRegister.set_user_attended(user, event_id) User.update_user_points(user, category, -points) else: User.update_user_points(user, category, points) EventRegister.set_user_attended(user, event_id) return jsonify({"message": "ok"}), 200
def auth_process(): data = request.get_json() if not data: abort(415) login = data.get("login", None) password = data.get("password", None) if not login or not password: return jsonify({"status": "fail", "message": "Вы должны ввести логин и пароль"}) try: user = User.get(User.login == login) except User.DoesNotExist: return jsonify({"status": "fail", "message": "Логин или пароль неправильные"}) rounds, password_hash, salt = parse_hashed_password(user.password) if hash_password(password, rounds, salt) != user.password: return jsonify({"status": "fail", "message": "Логин или пароль неправильные"}) safe_session = SafeSession.create(user=user, salt=generate_random_bytes_in_base64(32), session_key=generate_random_bytes_in_base64(32), session_expire=datetime.utcnow() + SESSION_ALIVE_TIME, client_ip=request.remote_addr) session["safe_id"] = safe_session.id session["safe_salt"] = safe_session.salt return jsonify({ "status": "ok", "sessionKey": safe_session.session_key, "userPrivateData": user.private_data, })
def tester_method(): email=request.form['email'] print(email) user=User.get_by_email(email) Database.update("users",{"email":email},{"printdata":"no"}) return "done"
def register_user(): email=request.form['email'] password=request.form['password'] if (email is "") or (password is ""): flash("Please fill email id and password") else: user_data = Database.find_one('users', {'email': email}) if not Utils.email_is_valid(email): flash("Your email has a invalid format.") elif user_data is not None: flash("User email id already exists!") else: User.register(email,password) return render_template('profile.html', email=session['email']) return render_template('register.html')
def view_event_registrations(event_id): if session.contains('email') and session['email'] is not None: if User.get_user_permissions(session['email']) == 'admin': users = EventRegister.list_registered_users(event_id) return render_template('admin-event-registrations.html', users=users, event_id=event_id) else: abort(401)
def login_user(): email=request.form['email'] password=request.form['password'] if (email is "") or (password is ""): flash("Please fill email id and password") return render_template('login.html') if User.login_valid(email,password): User.login(email) else: flash("Invalid credentials") session['email']=None return render_template('login.html') return render_template('profile.html',email=session['email'])
def test_method(): email=request.form['email'] print(email) user=User.get_by_email(email) print (user.json()) k=user.json() k['_id']=str(k['_id']) return jsonify({"status":k['printdata']})
def edit_uni_page(): if session.contains('email') and session['email'] is not None: if User.get_user_permissions(session['email']) == 'admin': universities = University.get_uni_list() return render_template('university-update.html', universities=universities) else: abort(401)
def login(): if len(request.form) == 0: return render_template('sign-in-up.html') else: username = request.form['username'] password = request.form['password'] user = User.get_user_by_login_n_password(username, password) login_user(user) return redirect('/admin')
def login_user(): user_email = request.form['email'] user_password = request.form['password'] if User.check_login(user_email, user_password): session['email'] = user_email return redirect(url_for('index')) else: return redirect(url_for('login_page', error_message="Your username or password was incorrect."))
def register_user(): user_email = request.form['email'] user_password = request.form['password'] if User.register_user(user_email, user_password): session['email'] = user_email return redirect(url_for('index')) else: return redirect(url_for('register_page', error_message="User exists"))
def create_new_post(blog_id): if request.method=='GET': return render_template('new_post.html',blog_id=blog_id) else: title=request.form['title'] content=request.form['content'] user=User.get_by_email(session['email']) new_post=Post(blog_id,title,content,user.email) new_post.save_to_mongo() return make_response(blog_posts(blog_id))
def test_user_json(self): email = "*****@*****.**" encrypted_password = "******" country = "Spain" university = "Abertay" user = User(email, encrypted_password) user.permissions = Permissions.default().name user.data['country'] = country user.data['university'] = university self.assertEqual(user.json(), { "email": email, "password": encrypted_password, "country": country, "university": university, "permissions": "user" })
def create_new_blog(): if request.method=='GET': return render_template('new_blog.html') else: title=request.form['title'] description=request.form['description'] user=User.get_by_email(session['email']) blog=Blog(user.email,title,description,user._id) blog.save_to_mongo() return make_response(user_blogs(user._id))
def admin_view_profile(user_email): if session.contains('email') and session['email'] is not None: if User.get_user_permissions(session['email']) == 'admin': profile = User.find_by_email(user_email) events = profile.get_registered_events(profile.email) totalpoints = profile.total_points() attended_events = profile.get_all_attended(profile.email) current_date = datetime.now() permissions = User.get_user_permissions(session['email']) user_points = profile.data['points'] if 'points' in profile.data.keys() else None awards = [] if user_points is not None: awards = Award.check_user_awards(profile.data['points']) return render_template('user-profile.html', email=user_email, profile=profile, events=events, totalpoints=totalpoints, rank=profile.get_point_rank(), permissions=permissions, date=current_date, attended_events=attended_events, awards=awards) else: abort(401)
def get_private_data(): safe_session = get_safe_session() if not safe_session: return jsonify(__auth_error) user = User.get(User.id == safe_session.user_id) return jsonify({ "status": "ok", "privateData": user.private_data })
async def store(request: Request): with connection.atomic() as transaction: data = request.json print(data, request.json) validator = ModelValidator(User(**data)) validator.validate() if bool(validator.errors): return response.json(validator.errors, status=400) user: User = User.create(**data) _user = model_to_dict(user, recurse=False, backrefs=True) # _user = json.dumps(_user, cls=Serialize) # dumps(body, **kwargs) return response.json(_user, status=201, dumps=json.dumps, cls=Serialize)
def register(): if request.method == 'POST': check_email = User.query.filter_by(email=request.form['email']).first() if check_email: # if email taken flash('Email already taken', 'warning') # we alert the user # then reload the register page again return redirect(url_for('register')) # if email not taken, we add new user to the database # we start with create an object for new_user new_user = User(name=request.form['name'], email=request.form['email']) # raw password will be hashed using the generate_password method new_user.generate_password(request.form['password']) db.session.add(new_user) # then we add new user to our session db.session.commit( ) # then we commit to our database (kind of like save to db) login_user(new_user) # then we log this user into our system flash('Successfully create an account and logged in', 'success') return redirect(url_for('root')) # and redirect user to our root if current_user.is_authenticated: return redirect(url_for('root')) return render_template('templates/register.html')
def create_new_blog(): if request.method == 'GET': return render_template('new_blog.html') else: title = request.form['title'] description = request.form['description'] user = User.get_by_email(session['email']) new_blog = Blog(user.email, title, description, user._id) new_blog.save_to_mongo() return make_response(user_blogs(user._id))
def create_new_post(blog_id): if request.method == 'GET': return render_template('new_post.html', blog_id=blog_id) else: title = request.form['title'] content = request.form['content'] user = User.get_by_email(session['email']) new_post = Post(blog_id, title, content, user.email) new_post.save_to_mongo() return make_response(blog_post(blog_id))
async def update(request: Request, uid: str): user = User.get_or_none(id=uid) if user is None: return response.json({'user': '******'}, status=404) data = request.json.copy() user_dict = user.json user_dict.update(data) errors = User.validate(**user_dict) if bool(errors): return response.json(errors, status=400) user_dict['updatedAt'] = datetime.utcnow() User.update(**user_dict).where(User.id == user.id).execute() return response.json(user_dict, dumps=json.dumps, cls=Serialize)
def leave_check(bot: telegram.Bot, update: telegram.Update): message = update.message chat_id = message.chat_id from_user: telegram.User = message.from_user from_uid = from_user.id if not from_user.is_bot: ChatUser.add(from_uid, chat_id) # убыло left_user = message.left_chat_member if left_user is not None and not left_user.is_bot: User.add_user(left_user) ChatUser.add(left_user.id, chat_id, left=True) if from_uid == left_user.id: # сам ливнул LeaveCollector.add_left(left_user.id, chat_id, message.date, from_uid) else: LeaveCollector.add_kick(left_user.id, chat_id, message.date, from_uid) # прибыло new_users = message.new_chat_members if new_users is not None and len(new_users) > 0: for new_user in new_users: if new_user.is_bot: continue User.add_user(new_user) ChatUser.add(new_user.id, chat_id) if from_uid == new_user.id: # вошел по инвайт-ссылке LeaveCollector.add_invite(new_user.id, chat_id, message.date, from_uid) else: LeaveCollector.add_join(new_user.id, chat_id, message.date, from_uid) send_welcome(bot, chat_id, new_user.id) # если ктоливнулыч что-то пишет, то запускаем сверку списков if 'ktolivnul' in CONFIG and from_uid == CONFIG['ktolivnul']: LeaveCollector.update_ktolivnul(chat_id)
def __super_stukach_alert( cls, uid: int) -> typing.Union[None, FSBDayTelegram.TelegramExecute]: recent_stucks = cache.get(f'{CACHE_PREFIX}__{uid}_recent_stucks') key_super_stukach_alert = f'{CACHE_PREFIX}__super_stukach_alert' if recent_stucks and recent_stucks >= 3 and not cache.get( key_super_stukach_alert): user = User.get(uid) cache.set(key_super_stukach_alert, True, time=30 * 60) return FSBDayTelegram.SendToChat( f'{user.get_username_or_link()} стучите помедленнее. Я не успеваю записывать.' ) return None
def create_new_blog(): if request.method == 'GET': # the user just arrive at the end point return render_template('new_blog.html') else: # user press the submit button title = request.form['title'] description = request.form['description'] user = User.get_by_email(session['email']) new_blog = Blog(user.email, title, description, user._id) new_blog.save_to_mongo() return make_response(user_blogs( user._id)) # we want to redirect user to his blog
def signup(): global status, dbo_user, pickle_filepath, orsen UserHandler.get_instance().set_global_curr_user( dbo_user.add_user(User(-1, name, code))) status = "storytelling" pickle_filepath = pickle_filepath + name initialize_orsen() temp_welcome = orsen.get_response( move_to_execute=orsen.dialogue_planner.get_welcome_message_type()) return "Alright " + name + " . " + temp_welcome
def create_new_blog(): if request.method == "GET": return render_template("new_blog.html") elif request.method == "POST": title = request.form["title"] description = request.form["description"] email = session["email"] current_user = User.get_by_email(email) new_blog = Blog(author=email, title=title, description=description, author_id=current_user.user_id) new_blog.save_to_mongo() return make_response(user_blogs_list())
def login_user(): #jsonObj = request.get_json() #print(jsonObj) #email = jsonObj['email'] #print(email) #password = jsonObj['password'] #print(password) email = request.form['email'] password = request.form['password'] if User.login_valid(email, password): #print('It is valid!') User.login(email) else: #print('It is not valid') session['email'] = None return render_template("profile.html", email=session['email'], password=password)
def test_event_new_message_with_no_friend(self, n1_send_message): user_chat_id = 10 user = factory(User).create(chat_id=user_chat_id, lang='ru', status=User.statuses['idle']) self.__run_bot('message/new', { 'sender_id': user.id, 'content': '', }) user_to_check = User.find_or_fail(user.id) self.assertEqual(user_to_check.status, User.statuses['active']) n1_send_message.assert_called_once_with(user_chat_id, locales[user.lang]['message_no_friend'], mock.ANY)
def update_user(user_id, args): user = User.get_user(user_id) if user is None: raise Error(StatusCode.NOT_FOUND, 'Cannot find user') if 'user_id' not in args: args['user_id'] = user['user_id'] if 'username' not in args: args['username'] = user['username'] if 'user_basic_info' not in args: args['user_basic_info'] = user['user_basic_info'] if 'user_contact_info' not in args: args['user_contact_info'] = user['user_contact_info'] if 'user_relationship_info' not in args: args['user_relationship_info'] = user['user_relationship_info'] new_user_id = args['user_id'] user = User.get_user(new_user_id) if user_id != new_user_id and user is not None: raise Error(StatusCode.BAD_REQUEST, 'User ID is already existed') user = User.update_user(user_id, new_user_id, args['username'], args['user_basic_info'], args['user_contact_info'], args['user_relationship_info']) return jsonify({'status': True, 'user': user}), StatusCode.OK
def create_new_post(): try: if request.method == 'GET': return render_template('new_post.html') else: title = request.form['title'] content = request.form['content'] user = User.get_by_email(session['email']) new_post = Post(title, content, user.email) new_post.save_to_mongo() return make_response(posts()) except KeyError: return make_response(posts())
def forgot_user(self, user_info, new_user_id, password_verifier, salt, iv_parameter): # delete user, then recreate user with new user_id and security information try: self.model = User(id=new_user_id, email=user_info.email, display_name=user_info.display_name, auth_source=user_info.auth_source, password_verifier=password_verifier, salt=salt, iv_parameter=iv_parameter, first_name=user_info.first_name, last_name=user_info.last_name, status=user_info.status, avatar=user_info.avatar, phone_number=user_info.phone_number, created_at=user_info.created_at) self.model.add() self.delete_user(user_info.id) except Exception as e: logger.error(e) raise Exception(Message.REGISTER_USER_FAILED)
async def create(self, db: AsyncSession, *, obj_in: UserCreate) -> User: db_obj = User( name=obj_in.name, email=obj_in.email, password=get_password_hash(obj_in.password), cpf=obj_in.cpf, ) db.add(db_obj) await db.commit() await db.refresh(db_obj) return db_obj
def update_user(self, id, request_data): try: self.__parse_update_user_request_data(request_data) new_user_data = User(request_data) result = self.db_service.update_user_by_id(id, new_user_data) if not result: return self.__send_response( 'error', 'Could not update user information.') return self.__send_response( 'info', 'user information successfully updated.') except InvalidRequestBody as err: print(err) return self.__send_response('error', err.msg)
def post(self): args = login_args.parse_args() name = args['name'] password = args['password'] db_user = User.objects(name=name).first() if db_user is None: return 404 passed = check_password_hash(db_user['password'], password) if passed: user = updateDocFields(db_user) token = createToken(user['id']) return user, 200, {'Set-Cookie': f'token={token}'} return 400
def login_user(): if request.method == 'POST': email = request.form['email'] password = request.form['password'] try: if User.is_login_valid(email, password): session['email'] = email return email except UserErrors.UserError as e: return e.message return render_template('users/login.html')
def get(self, filter_text): sort_options = search.SortOptions([ search.SortExpression(expression='name', direction=search.SortExpression.ASCENDING) ]) query_options = search.QueryOptions(limit=30, sort_options=sort_options) query = search.Query(query_string=filter_text, options=query_options) users_to_show = [] for document in User.GetSearchIndex().search(query): user = User.get_by_id(document.doc_id) if user: users_to_show.append(user) template = JINJA_ENVIRONMENT.get_template( 'admin/edit_users_table.html') self.response.write( template.render({ 'c': common.Common(self), 'users': users_to_show, }))
def create_new_road(): email = session['email'] if email is not None: if request.method == 'GET': user = User.get_by_email(email) if user.block == "ALL": return render_template('road_new.html', block=user.block) else: return render_template('road_new_block.html', block=user.block) else: block = request.form['block'] rd_code = request.form['rd_code'] rd_name = request.form['rd_name'] rd_cat = request.form['rd_cat'] rd_width = request.form['rd_width'] rd_ty_earth = request.form['rd_ty_earth'] rd_ty_gravel = request.form['rd_ty_gravel'] rd_ty_wb2 = request.form['rd_ty_wb2'] rd_ty_wb3 = request.form['rd_ty_wb3'] rd_ty_bt = request.form['rd_ty_bt'] rd_ty_cc = request.form['rd_ty_cc'] rd_length = request.form['rd_length'] last_upd_yr = request.form['last_upd_yr'] bus_rut_num = request.form['bus_rut_num'] pm_rout_code = request.form['pm_rout_code'] mgn_yn = request.form['mgn_yn'] hill_yn = request.form['hill_yn'] hab_name = request.form['hab_name'] roads = Road(block=block, rd_code=rd_code, rd_name=rd_name, rd_cat=rd_cat, rd_width=rd_width, rd_ty_earth=rd_ty_earth, rd_ty_gravel=rd_ty_gravel, rd_ty_wbm2=rd_ty_wb2, rd_ty_wbm3=rd_ty_wb3, rd_ty_bt=rd_ty_bt, rd_ty_cc=rd_ty_cc, rd_length=rd_length, last_upd_yr=last_upd_yr, bus_rut_num=bus_rut_num, hill_yn=hill_yn, mgn_yn=mgn_yn, pm_rout_code=pm_rout_code, hab_name=hab_name) roads.save_to_road() return render_template('record_saved.html', roads=roads) else: return render_template('login_fail.html')
def find_users(message: telegram.Message, usernames: List[str]) -> Tuple[List[str], Set[int], List[str]]: """ Ищет пользователей по таким юзернеймам. Возвращает кортеж: - список найденных uid - список найденных юзернеймов - список ненайденных юзернеймов """ not_found_usernames: List[str] = [] found_uids: Set[int] = set() found_usernames: List[str] = [] for username in usernames: uid = User.get_id_by_name(username) if uid is None: # на случай если вместо юзернейма указан цифровой user_id user = User.get(username) if user is not None: uid = user.uid if uid is None: not_found_usernames.append(username) continue found_uids.add(uid) found_usernames.append(username.lstrip('@')) # ищем упоминания людей без юзернейма for entity, _ in message.parse_entities().items(): if entity.type == 'text_mention': uid = entity.user.id if uid is None: continue user = User.get(uid) if user is None: continue found_uids.add(uid) found_usernames.append(user.fullname) return not_found_usernames, found_uids, found_usernames
def test_check_email(): from src.models.user import User u = User() assert u.check("email", "*****@*****.**") assert u.check("email", "*****@*****.**") == "Email is not unique" assert u.check("email", "testy123test.com") == "Email does not contain @" assert u.check("email", "testy123@testcom") == "Email does not contain ." assert u.check("email", "@.") == "Email length must be at least 5" assert u.check( "email", "*****@*****.**" ) == "Email length must be at most 120"
def format_chat_users(chat_id: int, uids: Iterable[int]) -> List[str]: """ Возвращает юзернеймы (с тегами) тех uids, что есть в чате. """ users = [] chat_uids: Set[int] = {chat_user.uid for chat_user in ChatUser.get_all(chat_id)} for uid in uids: user = User.get(uid) if user is None: continue if uid not in chat_uids: continue users.append(user.get_username_or_link()) return users
def save_user(self, request_data): try: self.__parse_new_user_request_data(request_data) new_user = User(request_data) result = self.db_service.insert_user(new_user) if not result: return self.__send_response('error', 'user could not be created.') return self.__send_response('info', 'user successfully created.') except ExistingUser as err: return self.__send_response('error', err.msg) except InvalidRequestBody as err: print(err) return self.__send_response('error', err.msg)
def blog_posts(blog_id): blog = Blog.from_mongo(blog_id) user = User.get_by_id(blog.author_id) if user.email == session['email']: myPage = True else: myPage = False posts = blog.get_posts() return render_template('posts.html', posts=posts, blog_title=blog.title, blog_id=blog._id, myPage=myPage)
def upload_image(): file = request.files['file'] target = os.path.abspath("src/images") if not os.path.isdir(target): os.mkdir(target) filename = secure_filename(file.filename) destination = "/".join([target, filename]) file.save(destination) res = main_detection(filename) user = User(img=filename, result_number=res) db_session.add(user) db_session.commit() returnData = {"message": "Successfully Uploaded Image", "result": res} return json.dumps(returnData)
def get(self): states = [] people_to_fetch = [] for user in User.query().iter(): if user.state and user.wca_person: states.append(user.state) people_to_fetch.append(user.wca_person) people_to_put = [] for person, state in zip(ndb.get_multi(people_to_fetch), states): if person: person.state = state people_to_put.append(person) ndb.put_multi(people_to_put)
def set_user(self): try: name = input('Username: ').strip() message = self._new_user_message(name) self.client_socket.send_message(message) response = self.recv_and_show_new_message() if not response.success: self.set_user() else: self.user = User(message.content) except socket.error as e: self.client_socket.exit( self.client_socket.format(self.client_socket.UNKNOWN_PROBLEM, e), 1)
def forget(): if current_user.is_authenticated: return redirect(url_for('userbp.root')) if request.method == "POST": user = User(email=request.form['email']).check_user() if not user: print("Account does not exist") return redirect(url_for('userbp.forget')) s = URLSafeSerializer(app.secre_key) token = s.dumps(user.email, salt="RESET_PASSWORD") send_mail(token, user.email, user.name) print('OK') return redirect(url_for('userbp.login')) return render_template('forget.html')