Skip to content

Commit

Permalink
Merge pull request #90 from SunbirdAI/google_auth
Browse files Browse the repository at this point in the history
Improved auth function
  • Loading branch information
yigagilbert authored Nov 5, 2024
2 parents aecf50c + 73196f8 commit 41ccfd1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Binary file modified app/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions app/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,18 @@ async def change_password(

return {"message": "Password change successful", "success": True}

@router.get("/google/login")
@router.get("/google/login", name='"auth:google_login"' )
async def google_login(request: Request):
# Get the redirect URI from the request
redirect_uri = request.url_for('google_callback')
redirect_uri = request.url_for('auth:google_callback')

# Store the intended destination in session
request.session['next'] = str(request.query_params.get('next', '/'))

# Redirect to Google login
return await oauth.google.authorize_redirect(request, redirect_uri)

@router.get("/google/callback")
@router.get("/google/callback", name='auth:google_callback')
async def google_callback(request: Request, db: AsyncSession = Depends(get_db)):
try:
# Get token from Google
Expand Down
Binary file added app/templates/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions app/templates/auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@

<!-- Add Google Sign-In Button -->
<div class="mt-4 text-center">
<a href="{{ url_for('auth/google_login') }}" class="text-blue-500 hover:text-blue-600 font-semibold">
<a href="{{ url_for('auth:google_login') }}" class="text-blue-500 hover:text-blue-600 font-semibold">
Sign in with Google
</a>
</div>

<!-- Add Google Sign-In Button -->
<div class="mt-4 text-center">
<a href="{{ url_for('auth/google_login') }}"
<a href="{{ url_for('auth:google_login') }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<img src="https://developers.google.com/identity/images/g-logo.png" alt="Google logo" class="w-5 h-5 mr-2">
</a>
Expand Down

0 comments on commit 41ccfd1

Please sign in to comment.