* feat(web): show recovery codes * feat(web): add recovery sign in * fix: copy * fix: styles * feat: add "copy to clipboard" button * style: copy * fix: copy button bg * style: singularize recovery codes * style: singularize recovery codes * feat: password validation Co-authored-by: Aman Harwara <amanharwara@protonmail.com> Co-authored-by: Mo <mo@standardnotes.com>
24 lines
940 B
TypeScript
24 lines
940 B
TypeScript
import { AuthClientInterface } from '@standardnotes/services'
|
|
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
|
import { SettingName } from '@standardnotes/settings'
|
|
|
|
import { SettingsClientInterface } from '@Lib/Services/Settings/SettingsClientInterface'
|
|
|
|
export class GetRecoveryCodes implements UseCaseInterface<string> {
|
|
constructor(private authClient: AuthClientInterface, private settingsClient: SettingsClientInterface) {}
|
|
|
|
async execute(): Promise<Result<string>> {
|
|
const existingRecoveryCodes = await this.settingsClient.getSetting(SettingName.RecoveryCodes)
|
|
if (existingRecoveryCodes !== undefined) {
|
|
return Result.ok(existingRecoveryCodes)
|
|
}
|
|
|
|
const generatedRecoveryCodes = await this.authClient.generateRecoveryCodes()
|
|
if (generatedRecoveryCodes === false) {
|
|
return Result.fail('Could not generate recovery code')
|
|
}
|
|
|
|
return Result.ok(generatedRecoveryCodes)
|
|
}
|
|
}
|