-
Notifications
You must be signed in to change notification settings - Fork 17
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 #426 from nih-sparc/add-login-functionality
Add login functionality
- Loading branch information
Showing
15 changed files
with
881 additions
and
14 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,14 @@ | ||
@import '@nih-sparc/sparc-design-system-components/src/assets/_variables.scss'; | ||
.el-menu--popup { | ||
min-width: fit-content !important; | ||
width: fit-content !important; | ||
padding: 0 !important; | ||
} | ||
|
||
.el-menu--popup::before, .el-menu--popup::after { | ||
display: none !important; | ||
} | ||
|
||
.el-menu--popup-bottom-start { | ||
margin-top: 8px !important; | ||
} |
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,3 @@ | ||
import { Auth } from '@aws-amplify/auth' | ||
import AWSConfig from '@/utils/awsExports.js' | ||
Auth.configure(AWSConfig) |
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 @@ | ||
/* eslint-disable */ | ||
var icon = require('vue-svgicon') | ||
icon.register({ | ||
'icon-sign-in': { | ||
width: 16, | ||
height: 16, | ||
viewBox: '0 0 24 24', | ||
data: '<path pid="0" d="M8 10c2.8 0 5-2.2 5-5s-2.2-5-5-5-5 2.2-5 5 2.2 5 5 5zm0-8c1.7 0 3 1.3 3 3S9.7 8 8 8 5 6.7 5 5s1.3-3 3-3zM15.9 18.9c-.5-3.5-3.3-6.3-6.8-6.8-2.1-.3-4.2.2-5.9 1.5S.4 16.7.1 18.9c-.1.5.3 1 .8 1.1H1c.5 0 .9-.4 1-.9.5-3.3 3.5-5.5 6.8-5.1 2.2.3 4.1 1.9 4.8 3.9H5c-.6 0-1 .4-1 1s.4 1 1 1h11.1l-.2-1z"/>' | ||
} | ||
}) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,58 @@ | ||
import { Auth } from '@aws-amplify/auth' | ||
import { pathOr } from 'ramda' | ||
|
||
export const state = () => ({ | ||
loggedInUser: null, | ||
loginError: '', | ||
logoutError: '', | ||
}) | ||
|
||
export const mutations = { | ||
SET_LOGGED_IN_USER(state, data){ | ||
state.loggedInUser = data | ||
}, | ||
UPDATE_USER_TOKEN(state, data) { | ||
state.userToken = data.token | ||
}, | ||
} | ||
|
||
export const actions = { | ||
async login({ dispatch }, providerName){ | ||
state.loginError = '' | ||
try { | ||
await Auth.federatedSignIn({customProvider: providerName}) | ||
await dispatch('fetchUser') | ||
} | ||
catch(err){ | ||
console.log(`Login Error [${err}]`) | ||
state.loginError = err.message | ||
} | ||
}, | ||
async logout({ dispatch }){ | ||
state.logoutError = '' | ||
try { | ||
await Auth.signOut() | ||
await dispatch('fetchUser') | ||
} | ||
catch(err){ | ||
console.log(`Logout Error [${err}]`) | ||
state.logoutError = err.message | ||
} | ||
}, | ||
async fetchUser({ commit }){ | ||
const session = await Auth.currentSession() | ||
if (session) { | ||
const user = await Auth.currentAuthenticatedUser() | ||
commit('SET_LOGGED_IN_USER', user) | ||
} | ||
}, | ||
} | ||
|
||
export const getters = { | ||
userToken (state, getters) { | ||
return pathOr('', ['signInUserSession', 'accessToken', 'jwtToken'], getters.user) | ||
}, | ||
user (state) { | ||
return state.loggedInUser | ||
} | ||
} |
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 @@ | ||
const awsConfig = { | ||
Auth: { | ||
region: process.env.AWS_REGION, | ||
userPoolId: process.env.AWS_USER_POOL_ID, | ||
userPoolWebClientId: process.env.AWS_USER_POOL_WEB_CLIENT_ID, | ||
authenticationFlowType: process.env.AWS_USER_AUTHENTICATION_FLOW_TYPE, | ||
oauth: { | ||
domain: process.env.AWS_OAUTH_DOMAIN, | ||
scope: process.env.AWS_OAUTH_SCOPE, | ||
redirectSignIn: process.env.AWS_OAUTH_REDIRECT_SIGN_IN_URL, | ||
redirectSignOut: process.env.AWS_OAUTH_REDIRECT_SIGN_OUT_URL, | ||
responseType: process.env.AWS_OAUTH_RESPONSE_TYPE | ||
} | ||
} | ||
} | ||
|
||
export default awsConfig |
Oops, something went wrong.