def PasswordResetPost(): if Authorization.isLoggedIn(session.get('user')): return redirect(url_for('Campus.List')) email = request.form.get('email') staff = StaffModel.findby('email', email) if len(staff) != 0: resetToken = str(uuid.uuid4()).replace('-', '') expires = time.time() + 30 * 60 # 30 minutes prm = PasswordResetModel() prm.setToken(resetToken) \ .setUserId(staff.getId()) \ .setUserType('staff') \ .setExpires(expires) \ .save() Email.sendEmail( email, 'password_reset', { 'password_reset_url': Config.getValue('APP_URL') + '/auth/password-reset/' + resetToken }) return render_template('auth/password_reset_sent.html')
def hook(): if not request.endpoint == 'static': Database.connect() #return if request.endpoint == 'static': return if request.endpoint is None: return if request.endpoint.startswith('Api.') or request.endpoint.startswith( 'Auth.'): return if not Authorization.isLoggedIn(session.get('user')): return redirect(url_for('Auth.Login'))
def LoginPost(): """ Example route, show information about system and current session. """ if Authorization.isLoggedIn(session.get('user')): return redirect(url_for('Campus.List')) email = request.form.get('email') password = request.form.get('password') staff = StaffModel.findBy('email', email) if len(staff) != 0: staff = staff[0] if staff.getPassword() == Security.hashPassword( password, staff.getSalt()): session['user'] = staff.getId() return redirect(url_for('Campus.List')) return render_template('auth/login.html', data={'email': email})
def PasswordResetConfirm(token): if Authorization.isLoggedIn(session.get('user')): return redirect(url_for('Campus.List')) return render_template('auth/password_reset_confirm.html', data={})
def Login(): """ Example route, show information about system and current session. """ if Authorization.isLoggedIn(session.get('user')): return redirect(url_for('Campus.List')) return render_template('auth/login.html')