-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to sign in with Google Accounts (#138)
* docs(contributor): contrib-readme-action has updated readme * google auth work in progress * docs: reset github bot change * common port for local debugging with vscode * remove debug logging * Add sign in with Google button * add ability to add sso user * only show google sso when google env vars set * add docs about new env vars * fix formatting on button * store sso user as boolean * make google login strategy async * clean-up duplicate variables * add translations * docs(contributor): contrib-readme-action has updated readme * use config not process env vars * google account linking and display names addition * support display name * remove addSSOUsers config option * remove displayname stuff * change property name * handle accounts already being linked * add redirect override environment variables * fix formatting * move to using google id instead of first email * cleaner migration handling * Fix ESLint violations * rootUrl changes * Fix failure flashes --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Wingy <[email protected]>
- Loading branch information
1 parent
3c71634
commit ae176ec
Showing
15 changed files
with
197 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import passport from 'passport' | ||
import express from 'express' | ||
|
||
export default function ({ db }) { | ||
const router = express.Router() | ||
|
||
router.get('/', passport.authenticate('google-login', { | ||
scope: ['openid', 'profile'] | ||
})) | ||
|
||
// Callback route once Google has authenticated the user | ||
router.get('/redirect', | ||
passport.authenticate('google-login', { | ||
successRedirect: '/', | ||
failureRedirect: '/login', | ||
failureMessage: 'Unable to sign-in using Google', | ||
failureFlash: true | ||
}) | ||
|
||
) | ||
|
||
router.get('/link', passport.authenticate('google-link', { | ||
scope: ['profile'] | ||
})) | ||
|
||
router.get('/link/redirect', | ||
passport.authenticate('google-link', { failureRedirect: '/profile', failureFlash: true }), | ||
(req, res) => { | ||
res.redirect('/profile') | ||
} | ||
) | ||
|
||
router.get('/unlink', async (req, res) => { | ||
try { | ||
const doc = await db.get(req.session.passport.user) | ||
delete doc.oauthConnections.google | ||
await db.put(doc) | ||
req.flash('success', _CC.lang('LOGIN_SSO_UNLINK_SUCCESS')) | ||
} catch (err) { | ||
req.flash('error', _CC.lang('LOGIN_SSO_UNLINK_FAILURE')) | ||
} | ||
res.redirect('/profile') | ||
}) | ||
|
||
return router | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters