def authenticate(self, Request): user = Auth(Request).login(Request.input('username'), Request.input('password')) if user and user.is_admin: return Request.redirect('/dashboard') elif not user: Request.session.flash('danger', 'Username or password is incorrect') else: Request.session.flash('danger', 'User does not have admin priviledges') Request.redirect('/dashboard/login')
def login_as_user(self, request: Request): if not request.get_cookie('_real_token'): request.cookie('_real_token', request.get_cookie('token')) Auth(request).login_by_id(request.input('user')) return request.redirect('/dashboard')
def show(self, Request, View): ''' Return the login page ''' return View('auth/login', {'app': application, 'Auth': Auth(Request)})