def handle_login_callback(request, auth_info, confirmed=True): profile_info = google.get_openid_profile(auth_info.access_token) openid_connect_info = OpenIDConnectInfo( auth_info.sub, profile_info.email, auth_info.openid_id, { 'full_name': profile_info.full_name, 'first_name': profile_info.first_name, 'last_name': profile_info.last_name } ) (existing_user, email) = OpenIDConnectBackend.pre_authenticate(openid_connect_info=openid_connect_info) if not confirmed and not existing_user: return redirect('auth:confirm_create_user', 'google', email) if 'email' in auth_info.state: email = auth_info.state['email'] else: email = None user = auth.authenticate(openid_connect_info=openid_connect_info, email=email) if not user: messages.error(request, _("OpenID Connect error")) return redirect('videos.videos.index') auth.login(request, user) next_url = auth_info.state.get('next') if next_url and is_safe_url(next_url): return HttpResponseRedirect(next_url) else: return redirect('videos.videos.index')
def handle_login_callback(request, auth_info): profile_info = google.get_openid_profile(auth_info.access_token) openid_connect_info = OpenIDConnectInfo( auth_info.sub, profile_info.email, auth_info.openid_id, { 'full_name': profile_info.full_name, 'first_name': profile_info.first_name, 'last_name': profile_info.last_name }) user = auth.authenticate(openid_connect_info=openid_connect_info) if not user: messages.error(request, _("OpenID Connect error")) return redirect('videos.videos.index') auth.login(request, user) next_url = auth_info.state.get('next') if next_url and is_safe_url(next_url): return HttpResponseRedirect(next_url) else: return redirect('videos.videos.index')
def run_authenticate(self, sub, email, openid_key=None, **profile_data): backend = OpenIDConnectBackend() return backend.authenticate(openid_connect_info=OpenIDConnectInfo( sub, email, openid_key, profile_data))