applyTokens method
Future<void>
applyTokens(
- AuthTokens tokens, {
- bool isNewUser = false,
})
Implementation
Future<void> applyTokens(AuthTokens tokens, {bool isNewUser = false}) async {
_tokenManager.setToken(tokens.accessToken);
final user = JwtHelper.getUserFromToken(tokens.accessToken);
await Future.wait([
_authStorage.saveRefreshToken(tokens.refreshToken),
_authStorage.saveUser(user),
]);
state = state.copyWith(
status: AuthStatus.authenticated,
user: user,
isNewUser: isNewUser,
error: null,
);
}