-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1907 from hypersign-protocol/google-login
Google login
- Loading branch information
Showing
8 changed files
with
231 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template></template> | ||
|
||
<script> | ||
import config from '../../config'; | ||
export default { | ||
name: 'Auth', | ||
components: {}, | ||
async mounted() { | ||
const routeHash = this.$route.hash; | ||
const accessToken = routeHash.split("&")[0].split("=")[1]; | ||
const authToken = routeHash.split("&")[5].split("=")[1]; | ||
const payload = { | ||
provider: 'Google', | ||
accessToken, | ||
authToken | ||
} | ||
const resp = await fetch(config.studioServer.BASE_URL + 'api/v1/login', { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Access-Control-Allow-Origin": "*", | ||
} | ||
, body: JSON.stringify(payload), | ||
method: 'POST' | ||
}) | ||
const data = await resp.json() | ||
if (data.authToken) { | ||
localStorage.setItem('authToken', data.authToken) | ||
const path = localStorage.getItem('path') | ||
if (path) { | ||
return this.$router.push(path) | ||
} else { | ||
return this.$router.push('/admin/dashboard') | ||
} | ||
} | ||
this.$router.push({ path: "/" }) | ||
} | ||
}; | ||
</script> | ||
|
||
<style></style> |
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,17 @@ | ||
import webAuth from '../utils/auth0Connection'; | ||
|
||
export default{ | ||
methods: { | ||
loginWithGoogle(){ | ||
webAuth.authorize( | ||
{ | ||
connection: "google-oauth2", | ||
redirectUri: window.location.origin + "/auth/google?", | ||
|
||
|
||
}); | ||
} | ||
}, | ||
|
||
|
||
} |
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,10 @@ | ||
import auth0 from "auth0-js"; | ||
import config from '../config' | ||
const newWebAuth = new auth0.WebAuth({ | ||
domain: config.auth0Domain, | ||
clientID: config.auth0LOGINCLIENTID, | ||
responseType: "token id_token", | ||
scope: "openid profile email", | ||
}) | ||
|
||
export default newWebAuth |
Oops, something went wrong.