-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-8214] New Device Verification Notice UI #12360
Changes from 28 commits
e0697a6
7fe1614
2affcdf
d82758a
d20b7a5
64598a0
5f41eed
f96ef7e
11396b0
954cfe9
f011abb
ecdff4b
4c335a2
fa70982
86b8e87
49dbc18
9f4514d
4880080
5c25444
10a8bae
407b5ca
83421c4
ac87737
7bf186c
4b1a2e9
6e6228a
847911c
e441795
e95377d
78fd445
37fb0ac
54d872a
659e2a7
84fb842
e3c74cd
072c58f
2ac259d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./new-device-verification-notice.guard"; | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||||||||||||||||
import { inject } from "@angular/core"; | ||||||||||||||||||
import { ActivatedRouteSnapshot, CanActivateFn, Router } from "@angular/router"; | ||||||||||||||||||
import { Observable, firstValueFrom, map } from "rxjs"; | ||||||||||||||||||
|
||||||||||||||||||
import { Account, AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||||||||||||||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; | ||||||||||||||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; | ||||||||||||||||||
|
||||||||||||||||||
import { NewDeviceVerificationNoticeService } from "../../../../vault/src/services/new-device-verification-notice.service"; | ||||||||||||||||||
|
||||||||||||||||||
export const NewDeviceVerificationNoticeGuard: CanActivateFn = async ( | ||||||||||||||||||
route: ActivatedRouteSnapshot, | ||||||||||||||||||
) => { | ||||||||||||||||||
const router = inject(Router); | ||||||||||||||||||
const configService = inject(ConfigService); | ||||||||||||||||||
const newDeviceVerificationNoticeService = inject(NewDeviceVerificationNoticeService); | ||||||||||||||||||
const accountService = inject(AccountService); | ||||||||||||||||||
|
||||||||||||||||||
if (route.queryParams["fromNewDeviceVerification"]) { | ||||||||||||||||||
return true; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const tempNoticeFlag = await configService.getFeatureFlag( | ||||||||||||||||||
FeatureFlag.NewDeviceVerificationTemporaryDismiss, | ||||||||||||||||||
); | ||||||||||||||||||
const permNoticeFlag = await configService.getFeatureFlag( | ||||||||||||||||||
FeatureFlag.NewDeviceVerificationPermanentDismiss, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
const currentAcct$: Observable<Account | null> = accountService.activeAccount$.pipe( | ||||||||||||||||||
map((acct) => acct), | ||||||||||||||||||
); | ||||||||||||||||||
const currentAcct = await firstValueFrom(currentAcct$); | ||||||||||||||||||
|
||||||||||||||||||
if (!currentAcct) { | ||||||||||||||||||
return router.createUrlTree(["/login"]); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const userItems$ = newDeviceVerificationNoticeService.noticeState$(currentAcct.id); | ||||||||||||||||||
const userItems = await firstValueFrom(userItems$); | ||||||||||||||||||
|
||||||||||||||||||
if ( | ||||||||||||||||||
userItems?.last_dismissal == null && | ||||||||||||||||||
(userItems?.permanent_dismissal == null || !userItems?.permanent_dismissal) && | ||||||||||||||||||
(tempNoticeFlag || permNoticeFlag) | ||||||||||||||||||
) { | ||||||||||||||||||
Comment on lines
+42
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ๏ธ (non-blocking) this logic could be cleaned up by deconstructing
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have this code altered in my following work so this is does not need to be changed here. |
||||||||||||||||||
return router.createUrlTree(["/new-device-notice"]); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
return true; | ||||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
โ Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed: 78fd445