Track rotated auth tokens
parent
ed146a582c
commit
b2dba9a15b
|
@ -34,6 +34,8 @@ export async function setupState() {
|
|||
if (!api.sessionManager.session && rootStore.session.isAuthed) {
|
||||
// reset session
|
||||
rootStore.session.clear()
|
||||
} else if (api.sessionManager.session) {
|
||||
rootStore.session.updateAuthTokens(api.sessionManager.session)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import {makeAutoObservable} from 'mobx'
|
||||
import {sessionClient as AtpApi} from '../../third-party/api/index'
|
||||
import type {SessionServiceClient} from '../../third-party/api/src/index'
|
||||
import type {
|
||||
SessionServiceClient,
|
||||
Session,
|
||||
} from '../../third-party/api/src/index'
|
||||
import type * as GetAccountsConfig from '../../third-party/api/src/client/types/com/atproto/server/getAccountsConfig'
|
||||
import {isObj, hasProp} from '../lib/type-guards'
|
||||
import {RootStoreModel} from './root-store'
|
||||
|
@ -88,6 +91,16 @@ export class SessionModel {
|
|||
this.data = data
|
||||
}
|
||||
|
||||
updateAuthTokens(session: Session) {
|
||||
if (this.data) {
|
||||
this.setState({
|
||||
...this.data,
|
||||
accessJwt: session.accessJwt,
|
||||
refreshJwt: session.refreshJwt,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private configureApi(): boolean {
|
||||
if (!this.data) {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue