Skip to content

Commit

Permalink
[PM-3198][PM-3199] Rename PasswordlessLoginStrategy (#6425)
Browse files Browse the repository at this point in the history
* rename to LoginWithDeviceLoginStrategy

* rename LoginWithDeviceComponent

* update translation for web route

* rename strategy to AuthRequestLoginStrategy

* rename PasswordlessLogInCredentials and PasswordlessCreateAuthRequest

* rename setPasswordlessAccessCode

* rename startPasswordlessLogin() in template files

* rename startPasswordlessLogin() for browser template file

* rename AuthenticationType.Passwordless

* standardize LogInStrategy to LoginStrategy

* standardize PasswordLogInStrategy to PasswordLoginStrategy

* standardize SsoLogInStrategy to SsoLoginStrategy

* standardize UserApiLogInStrategy to UserApiLoginStrategy

* standardize naming of login credentials

* rename log-in-credentials.ts to login-credentials.ts
  • Loading branch information
rr-bw authored Oct 25, 2023
1 parent 8dd17bd commit 5868d76
Show file tree
Hide file tree
Showing 38 changed files with 250 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="login-center">
</div>

<div class="resend-notification" *ngIf="showResendNotification">
<a (click)="startPasswordlessLogin()">{{ "resendNotification" | i18n }}</a>
<a (click)="startAuthRequestLogin()">{{ "resendNotification" | i18n }}</a>
</div>

<div class="footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Location } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Router } from "@angular/router";

import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthRequestCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth-request-crypto.service.abstraction";
Expand All @@ -22,10 +22,10 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";

@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/auth/popup/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="login-center">
<i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
</button>
<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless">
<button type="button" class="btn block" (click)="startPasswordlessLogin()">
<button type="button" class="btn block" (click)="startAuthRequestLogin()">
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { HintComponent } from "../auth/popup/hint.component";
import { HomeComponent } from "../auth/popup/home.component";
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/popup/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginComponent } from "../auth/popup/login.component";
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
Expand Down Expand Up @@ -90,13 +90,13 @@ const routes: Routes = [
},
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" },
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" },
},
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/src/popup/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { HintComponent } from "../auth/popup/hint.component";
import { HomeComponent } from "../auth/popup/home.component";
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/popup/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginComponent } from "../auth/popup/login.component";
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
Expand Down Expand Up @@ -125,7 +125,7 @@ import "../platform/popup/locales";
HomeComponent,
LockComponent,
LoginComponent,
LoginWithDeviceComponent,
LoginViaAuthRequestComponent,
LoginDecryptionOptionsComponent,
OptionsComponent,
GeneratorComponent,
Expand Down
18 changes: 9 additions & 9 deletions apps/cli/src/auth/commands/login.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-p
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
import { ForceResetPasswordReason } from "@bitwarden/common/auth/models/domain/force-reset-password-reason";
import {
PasswordLogInCredentials,
SsoLogInCredentials,
UserApiLogInCredentials,
} from "@bitwarden/common/auth/models/domain/log-in-credentials";
PasswordLoginCredentials,
SsoLoginCredentials,
UserApiLoginCredentials,
} from "@bitwarden/common/auth/models/domain/login-credentials";
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
import { TwoFactorEmailRequest } from "@bitwarden/common/auth/models/request/two-factor-email.request";
Expand Down Expand Up @@ -179,7 +179,7 @@ export class LoginCommand {
}
try {
response = await this.authService.logIn(
new UserApiLogInCredentials(clientId, clientSecret)
new UserApiLoginCredentials(clientId, clientSecret)
);
} catch (e) {
// handle API key login failures
Expand All @@ -196,7 +196,7 @@ export class LoginCommand {
}
} else if (ssoCode != null && ssoCodeVerifier != null) {
response = await this.authService.logIn(
new SsoLogInCredentials(
new SsoLoginCredentials(
ssoCode,
ssoCodeVerifier,
this.ssoRedirectUri,
Expand All @@ -206,7 +206,7 @@ export class LoginCommand {
);
} else {
response = await this.authService.logIn(
new PasswordLogInCredentials(email, password, null, twoFactor)
new PasswordLoginCredentials(email, password, null, twoFactor)
);
}
if (response.requiresEncryptionKeyMigration) {
Expand All @@ -215,7 +215,7 @@ export class LoginCommand {
);
}
if (response.captchaSiteKey) {
const credentials = new PasswordLogInCredentials(email, password);
const credentials = new PasswordLoginCredentials(email, password);
const handledResponse = await this.handleCaptchaRequired(twoFactor, credentials);

// Error Response
Expand Down Expand Up @@ -586,7 +586,7 @@ export class LoginCommand {

private async handleCaptchaRequired(
twoFactorRequest: TokenTwoFactorRequest,
credentials: PasswordLogInCredentials = null
credentials: PasswordLoginCredentials = null
): Promise<AuthResult | Response> {
const badCaptcha = Response.badRequest(
"Your authentication request has been flagged and will require user interaction to proceed.\n" +
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LoginGuard } from "../auth/guards/login.guard";
import { HintComponent } from "../auth/hint.component";
import { LockComponent } from "../auth/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/login/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/login/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/login/login-via-auth-request.component";
import { LoginComponent } from "../auth/login/login.component";
import { RegisterComponent } from "../auth/register.component";
import { RemovePasswordComponent } from "../auth/remove-password.component";
Expand Down Expand Up @@ -46,11 +46,11 @@ const routes: Routes = [
},
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
},
{ path: "2fa", component: TwoFactorComponent },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4>{{ "fingerprintPhraseHeader" | i18n }}</h4>
</div>

<div class="section" *ngIf="showResendNotification">
<a [routerLink]="[]" disabled="true" (click)="startPasswordlessLogin()">{{
<a [routerLink]="[]" disabled="true" (click)="startAuthRequestLogin()">{{
"resendNotification" | i18n
}}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Location } from "@angular/common";
import { Component, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { Router } from "@angular/router";

import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
Expand All @@ -25,10 +25,10 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { EnvironmentComponent } from "../environment.component";

@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
</button>
</div>
<div class="buttons-row" *ngIf="showLoginWithDevice">
<button type="button" class="btn block" (click)="startPasswordlessLogin()">
<button type="button" class="btn block" (click)="startAuthRequestLogin()">
<i class="bwi bwi-mobile" aria-hidden="true"></i>
{{ "logInWithAnotherDevice" | i18n }}
</button>
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/auth/login/login.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components
import { SharedModule } from "../../app/shared/shared.module";

import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./login-with-device.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginComponent } from "./login.component";

@NgModule({
imports: [SharedModule, RouterModule],
declarations: [
LoginComponent,
LoginWithDeviceComponent,
LoginViaAuthRequestComponent,
EnvironmentSelectorComponent,
LoginDecryptionOptionsComponent,
],
exports: [LoginComponent, LoginWithDeviceComponent],
exports: [LoginComponent, LoginViaAuthRequestComponent],
})
export class LoginModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h4 class="tw-font-semibold">{{ "fingerprintPhraseHeader" | i18n }}</h4>
</div>

<div class="tw-my-10" *ngIf="showResendNotification">
<a [routerLink]="[]" disabled="true" (click)="startPasswordlessLogin()">{{
<a [routerLink]="[]" disabled="true" (click)="startAuthRequestLogin()">{{
"resendNotification" | i18n
}}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Router } from "@angular/router";

import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthRequestCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth-request-crypto.service.abstraction";
Expand All @@ -21,10 +21,10 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
import { StateService } from "../../core";

@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
type="button"
[block]="true"
buttonType="secondary"
(click)="startPasswordlessLogin()"
(click)="startAuthRequestLogin()"
>
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/app/auth/login/login.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { CheckboxModule } from "@bitwarden/components";
import { SharedModule } from "../../../app/shared";

import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./login-with-device.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginComponent } from "./login.component";

@NgModule({
imports: [SharedModule, CheckboxModule],
declarations: [LoginComponent, LoginWithDeviceComponent, LoginDecryptionOptionsComponent],
exports: [LoginComponent, LoginWithDeviceComponent, LoginDecryptionOptionsComponent],
declarations: [LoginComponent, LoginViaAuthRequestComponent, LoginDecryptionOptionsComponent],
exports: [LoginComponent, LoginViaAuthRequestComponent, LoginDecryptionOptionsComponent],
})
export class LoginModule {}
8 changes: 4 additions & 4 deletions apps/web/src/app/oss-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AcceptOrganizationComponent } from "./auth/accept-organization.componen
import { HintComponent } from "./auth/hint.component";
import { LockComponent } from "./auth/lock.component";
import { LoginDecryptionOptionsComponent } from "./auth/login/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./auth/login/login-with-device.component";
import { LoginViaAuthRequestComponent } from "./auth/login/login-via-auth-request.component";
import { LoginComponent } from "./auth/login/login.component";
import { RecoverDeleteComponent } from "./auth/recover-delete.component";
import { RecoverTwoFactorComponent } from "./auth/recover-two-factor.component";
Expand Down Expand Up @@ -66,13 +66,13 @@ const routes: Routes = [
{ path: "login", component: LoginComponent, canActivate: [UnauthGuard] },
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
data: { titleId: "loginWithDevice" },
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
data: { titleId: "loginWithDevice" },
component: LoginViaAuthRequestComponent,
data: { titleId: "adminApprovalRequested" },
},
{ path: "2fa", component: TwoFactorComponent, canActivate: [UnauthGuard] },
{
Expand Down
Loading

0 comments on commit 5868d76

Please sign in to comment.