def login_view(request, provider=None): provider_ids = [p.id for p in registry.get_list()] if request.method == 'POST': email = request.POST['username'] password = request.POST['password'] prev_page = request.POST['prevPage'] user = authenticate(username=email.lower(), password=password) if user is not None and user.is_authenticated: login(request, user) redirect_url = prev_page if prev_page.startswith( '/') else '/index/?section=' + prev_page return redirect(redirect_url) else: messages.error(request, 'Incorrect Email or Password') return redirect('/index/?section=LogIn&prev=' + prev_page) if provider in provider_ids: return redirect(f'{provider}_login') else: return redirect('/index/?section=LogIn')
def login_view(request, provider=None): provider_ids = [p.id for p in registry.get_list()] if request.method == 'POST': email = request.POST['username'] password = request.POST['password'] prev_page = request.POST['prevPage'] prev_page_args = ast.literal_eval(request.POST['prevPageArgs']) user = authenticate(username=email.lower(), password=password) if user is not None and user.is_authenticated: login(request, user) redirect_url = '/' if prev_page.strip('/') == '' else section_url(prev_page, prev_page_args) return redirect(redirect_url) else: messages.error(request, 'Incorrect Email or Password') return redirect(section_url(FrontEndSection.LogIn, {'prev': prev_page})) if provider in provider_ids: return redirect(f'{provider}_login') else: return redirect(section_url(FrontEndSection.LogIn))