def load_user(self, request): ''' Load user into the request ''' request.set_user(Auth(request).user())
def logout(self, Request): Auth(Request).logout() return Request.redirect('/login')
def show(self, Request, Application): ''' Show the login page ''' return view('auth/login', {'app': Application, 'Auth': Auth(Request)})
def show(self, Request, View): ''' Show the registration page ''' return View('auth/register', { 'app': application, 'Auth': Auth(Request) })
def store(self, Request): if Auth(Request).login(Request.input('username'), Request.input('password')): Request.redirect('/home') else: Request.redirect('/login') return 'check terminal'
def logout(self, Request, Session): Auth(Request).logout() Session.flash('success', 'You\'re logged out. Have a great day!') return Request.redirect('/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)})
'QUERY_STRING': 'application=Masonite', 'RAW_URI': '/', 'SERVER_PROTOCOL': 'HTTP/1.1', 'HTTP_HOST': '127.0.0.1:8000', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', 'HTTP_COOKIE': 'setcookie=value', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7', 'HTTP_ACCEPT_LANGUAGE': 'en-us', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_CONNECTION': 'keep-alive', 'wsgi.url_scheme': 'http', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '62241', 'SERVER_NAME': '127.0.0.1', 'SERVER_PORT': '8000', 'PATH_INFO': '/', 'SCRIPT_NAME': '' } REQUEST = Request(wsgi_request).key( 'NCTpkICMlTXie5te9nJniMj9aVbPM6lsjeq5iDZ0dqY=') AUTH = Auth(REQUEST, object) def test_auth(): assert AUTH