Skip to content

Commit

Permalink
fix: add login option to avoid next route call in login function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Mar 7, 2023
1 parent 589e018 commit 5343326
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/desktop/views/login/views/EnterPinView.svelte
Expand Up @@ -95,7 +95,7 @@
isBusy = true
const isVerified = await Platform.PincodeManager.verify($activeProfile?.id, pinCode)
if (isVerified) {
void login()
void login({ avoidNextRoute: updateRequired })
$loginRouter.next()
} else {
shake = true
Expand Down
Expand Up @@ -5,19 +5,20 @@
import { localize } from '@core/i18n'
import { unlockStronghold } from '@core/profile'
import { loginRouter } from '@core/router'
import { loginRouter, updateStrongholdRouter } from '@core/router'
let password: string = ''
let passwordError: string = ''
async function onSubmit(): Promise<void> {
try {
await unlockStronghold(password)
$updateStrongholdRouter.next()
} catch (err) {
passwordError = localize(err.message) ?? err.message
return
}
return // TODO: implement update stronghold functionality
return
}
function onBackClick(): void {
Expand Down
Expand Up @@ -136,7 +136,9 @@ export async function login(loginOptions?: ILoginOptions): Promise<void> {
lastActiveAt.set(new Date())
loggedIn.set(true)
setTimeout(() => {
loginRouter?.next()
if (!loginOptions?.avoidNextRoute) {
loginRouter?.next()
}
resetLoginProgress()
}, 500)

Expand Down
@@ -1,10 +1,10 @@
import { setStrongholdPassword } from '@core/profile-manager'
import { activeProfile } from '@core/profile'
import { activeProfile, IProfile } from '@core/profile'
import { get } from 'svelte/store'
import { setTimeStrongholdLastUnlocked } from '@core/profile/stores'

export async function unlockStronghold(password: string): Promise<void> {
const { isStrongholdLocked } = get(activeProfile)
export async function unlockStronghold(password: string, profile: IProfile = get(activeProfile)): Promise<void> {
const { isStrongholdLocked } = profile
if (get(isStrongholdLocked)) {
try {
await setStrongholdPassword(password)
Expand Down
Expand Up @@ -2,4 +2,5 @@ export interface ILoginOptions {
isFromOnboardingFlow?: boolean
shouldRecoverAccounts?: boolean
shouldCreateAccount?: boolean
avoidNextRoute?: boolean
}

0 comments on commit 5343326

Please sign in to comment.