-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): refresh expired token instead of logout immediately (#645)
- Loading branch information
Showing
34 changed files
with
672 additions
and
672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ describe('AuthGuard', () => { | |
it('should return true if user is authenticated', (done) => { | ||
store.setState({ auth: { user: { id: '1', email: '[email protected]' } } }) | ||
|
||
// @ts-ignore | ||
const canActivate = guard.canActivate(null, null) as Observable<boolean> | ||
|
||
canActivate.subscribe((isAuth) => { | ||
|
@@ -51,6 +52,7 @@ describe('AuthGuard', () => { | |
const urlTree = router.createUrlTree(['/auth']) | ||
|
||
createUrlTreeSpy.and.returnValue(urlTree) | ||
// @ts-ignore | ||
const canActivate = guard.canActivate(null, null) as Observable<boolean | UrlTree> | ||
|
||
canActivate.subscribe((result) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
// FILEPATH: /Users/pmueller/workspace/intern/cashbox/frontend/src/app/auth/auth.model.spec.ts | ||
|
||
import { Auth } from './auth.model'; | ||
import { Auth } from './auth.model' | ||
|
||
describe('Auth', () => { | ||
let auth: Auth; | ||
let auth: Auth | ||
|
||
beforeEach(() => { | ||
auth = new Auth('[email protected]', 'token', new Date()); | ||
}); | ||
auth = new Auth('[email protected]', 'token', new Date()) | ||
}) | ||
|
||
it('should be created', () => { | ||
expect(auth).toBeTruthy(); | ||
}); | ||
expect(auth).toBeTruthy() | ||
}) | ||
|
||
it('should return token if token expiration date is in the future', () => { | ||
auth = new Auth('[email protected]', 'token', new Date(new Date().getTime() + 10000)); | ||
expect(auth.token).toEqual('token'); | ||
}); | ||
|
||
it('should return null if token expiration date is in the past', () => { | ||
auth = new Auth('[email protected]', 'token', new Date(new Date().getTime() - 10000)); | ||
expect(auth.token).toBeNull(); | ||
}); | ||
|
||
it('should return null if token expiration date is not set', () => { | ||
auth = new Auth('[email protected]', 'token', null); | ||
expect(auth.token).toBeNull(); | ||
}); | ||
}); | ||
auth = new Auth('[email protected]', 'token', new Date(new Date().getTime() + 10000)) | ||
expect(auth.token).toEqual('token') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.