def login_page(request): """ Display the login form. """ # Redirect user to LMS login page if `DISABLE_STUDIO_SSO_OVER_LMS` feature # flag is not enabled and user tries to access the signin page using URL. if not settings.FEATURES.get('DISABLE_STUDIO_SSO_OVER_LMS', False): return redirect_with_get(settings.FRONTEND_LOGIN_URL, request.GET, False) csrf_token = csrf(request)['csrf_token'] if request.user.is_authenticated: return redirect('/course/') if (settings.FEATURES['AUTH_USE_CERTIFICATES'] and ssl_get_cert_from_request(request)): # SSL login doesn't require a login view, so redirect # to course now that the user is authenticated via # the decorator. next_url = request.GET.get('next') if next_url: return redirect(next_url) else: return redirect('/course/') if settings.FEATURES.get('AUTH_USE_CAS'): # If CAS is enabled, redirect auth handling to there return redirect(reverse('cas-login')) return render_to_response( 'login.html', { 'csrf': csrf_token, 'forgot_password_link': "//{base}/login#forgot-password-modal".format(base=settings.LMS_BASE), 'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME), } )
def signup(request): """ Display the signup form. """ csrf_token = csrf(request)['csrf_token'] if request.user.is_authenticated: return redirect('/course/') if settings.FEATURES.get('AUTH_USE_CERTIFICATES_IMMEDIATE_SIGNUP'): # Redirect to course to login to process their certificate if SSL is enabled # and registration is disabled. return redirect_with_get('login', request.GET, False) return render_to_response('register.html', {'csrf': csrf_token})