-
Notifications
You must be signed in to change notification settings - Fork 1
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 #5 from useElven/native-auth-fix
fix native auth login token handling
- Loading branch information
Showing
11 changed files
with
185 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
build | ||
.vscode |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,26 @@ | ||
import { getNativeAuthClient } from 'src/utils/getNativeAuthClient'; | ||
import { | ||
setLoginInfoState, | ||
loginInfoState, | ||
setLoggingInState, | ||
} from '../../store/auth'; | ||
import { errorParse } from 'src/utils/errorParse'; | ||
|
||
export const getLoginToken = async () => { | ||
const client = getNativeAuthClient(); | ||
let token = loginInfoState.loginToken; | ||
|
||
if (!token) { | ||
try { | ||
setLoggingInState('pending', true); | ||
token = await client.initialize(); | ||
} catch (e) { | ||
setLoggingInState('error', errorParse(e)); | ||
} finally { | ||
setLoggingInState('pending', false); | ||
} | ||
} | ||
|
||
setLoginInfoState('loginToken', token); | ||
return token; | ||
}; |
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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
import { NativeAuthClient } from '@multiversx/sdk-native-auth-client'; | ||
import { configState } from '../store/config'; | ||
|
||
export const getNativeAuthClient = () => | ||
new NativeAuthClient({ apiUrl: configState.apiAddress }); |