Avivash/update old username format in init (#106)
This commit is contained in:
parent
b0b9a2020e
commit
14b554d098
|
|
@ -3,7 +3,7 @@ import * as webnative from 'webnative'
|
||||||
import { dev } from '$app/environment'
|
import { dev } from '$app/environment'
|
||||||
import { filesystemStore, sessionStore } from '../stores'
|
import { filesystemStore, sessionStore } from '../stores'
|
||||||
import { getBackupStatus, type BackupStatus } from '$lib/auth/backup'
|
import { getBackupStatus, type BackupStatus } from '$lib/auth/backup'
|
||||||
import { USERNAME_STORAGE_KEY } from '$lib/auth/account'
|
import { USERNAME_STORAGE_KEY, createDID } from '$lib/auth/account'
|
||||||
import { webnativeNamespace } from '$lib/app-info'
|
import { webnativeNamespace } from '$lib/app-info'
|
||||||
|
|
||||||
export const initialize = async (): Promise<void> => {
|
export const initialize = async (): Promise<void> => {
|
||||||
|
|
@ -19,7 +19,16 @@ export const initialize = async (): Promise<void> => {
|
||||||
// Authed
|
// Authed
|
||||||
backupStatus = await getBackupStatus(program.session.fs)
|
backupStatus = await getBackupStatus(program.session.fs)
|
||||||
|
|
||||||
const fullUsername = await program.components.storage.getItem(USERNAME_STORAGE_KEY) as string
|
let fullUsername = await program.components.storage.getItem(USERNAME_STORAGE_KEY) as string
|
||||||
|
|
||||||
|
// If the user is migrating from a version webnative-app-template before https://github.com/webnative-examples/webnative-app-template/pull/97/files#diff-a180510e798b8f833ebfdbe691c5ec4a1095076980d3e2388de29c849b2b8361R44,
|
||||||
|
// their username won't contain a did, so we will need to manually append a DID and add it storage here
|
||||||
|
if (!fullUsername) {
|
||||||
|
const did = await createDID(program.components.crypto)
|
||||||
|
fullUsername = `${program.session.username}#${did}`
|
||||||
|
await program.components.storage.setItem(USERNAME_STORAGE_KEY, fullUsername)
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
sessionStore.set({
|
sessionStore.set({
|
||||||
username: {
|
username: {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@
|
||||||
$themeStore.selectedTheme === 'light' ? '#FAFAFA' : '#171717',
|
$themeStore.selectedTheme === 'light' ? '#FAFAFA' : '#171717',
|
||||||
padding: 0,
|
padding: 0,
|
||||||
width: 250,
|
width: 250,
|
||||||
height: 250
|
height: 250,
|
||||||
|
join: true
|
||||||
}).svg()
|
}).svg()
|
||||||
|
|
||||||
initAccountLinkingProducer(hashedUsername)
|
initAccountLinkingProducer(hashedUsername)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue