Commit 75c6e468 authored by David Burke's avatar David Burke

Rename forgot password to reset password for consistency

parent 6c0c3161
Pipeline #36132564 passed with stage
in 7 minutes and 29 seconds
......@@ -24,7 +24,7 @@ import { UserService } from "./user";
import { Store } from "@ngrx/store";
import { IState } from "../app.reducers";
import { HttpErrorResponse } from "@angular/common/http";
import { SetPasswordActionTypes } from "./forgot-password/set-password/set-password.actions";
import { SetPasswordActionTypes } from "./reset-password/set-password/set-password.actions";
@Injectable()
export class LoginEffects {
......@@ -60,15 +60,20 @@ export class LoginEffects {
);
@Effect({ dispatch: false })
loginSuccess$ = this.actions$.ofType(AccountActionTypes.LOGIN_SUCCESS, SetPasswordActionTypes.SET_PASSWORD_SUCCESS).pipe(
tap(() => {
if (IS_EXTENSION) {
this.router.navigate(["/popup"]);
} else {
this.router.navigate(["/list"]);
}
})
);
loginSuccess$ = this.actions$
.ofType(
AccountActionTypes.LOGIN_SUCCESS,
SetPasswordActionTypes.SET_PASSWORD_SUCCESS
)
.pipe(
tap(() => {
if (IS_EXTENSION) {
this.router.navigate(["/popup"]);
} else {
this.router.navigate(["/list"]);
}
})
);
@Effect({ dispatch: false })
loginRedirect$ = this.actions$
......
......@@ -19,18 +19,18 @@ import * as fromRegister from "./register/register.reducer";
import * as fromChangePassword from "./change-password/change-password.reducer";
import * as fromDeleteAccount from "./delete/delete.reducer";
import * as fromErrorReporting from "./error-reporting/error-reporting.reducer";
import * as fromForgotPassword from "./forgot-password/forgot-password.reducer";
import * as fromResetPasswordVerify from "./forgot-password/reset-password-verify/reset-password-verify.reducer";
import * as fromSetPassword from "./forgot-password/set-password/set-password.reducer";
import * as fromResetPassword from "./reset-password/reset-password.reducer";
import * as fromResetPasswordVerify from "./reset-password/reset-password-verify/reset-password-verify.reducer";
import * as fromSetPassword from "./reset-password/set-password/set-password.reducer";
import {
ResetPasswordVerifyActionTypes,
ResetPasswordVerifyActionsUnion
} from "./forgot-password/reset-password-verify/reset-password-verify.actions";
} from "./reset-password/reset-password-verify/reset-password-verify.actions";
import {
SetPasswordSuccess,
SetPasswordActionTypes,
ForceSetPassword
} from "./forgot-password/set-password/set-password.actions";
} from "./reset-password/set-password/set-password.actions";
export interface IAuthState {
email: string | null;
......@@ -125,7 +125,7 @@ export interface IAccountState {
changePassword: fromChangePassword.IChangePasswordState;
deleteAccount: fromDeleteAccount.IDeleteAccountState;
errorReporting: fromErrorReporting.IState;
forgotPassword: fromForgotPassword.IForgotPasswordState;
resetPassword: fromResetPassword.IResetPasswordState;
resetPasswordVerify: fromResetPasswordVerify.IResetPasswordVerifyState;
setPassword: fromSetPassword.ISetPasswordState;
}
......@@ -138,7 +138,7 @@ export const reducers: ActionReducerMap<IAccountState> = {
changePassword: fromChangePassword.reducer,
deleteAccount: fromDeleteAccount.reducer,
errorReporting: fromErrorReporting.reducer,
forgotPassword: fromForgotPassword.reducer,
resetPassword: fromResetPassword.reducer,
resetPasswordVerify: fromResetPasswordVerify.reducer,
setPassword: fromSetPassword.reducer
};
......@@ -324,25 +324,25 @@ export const getErrorReportingHasStarted = createSelector(
fromErrorReporting.getHasStarted
);
export const selectForgotPasswordState = createSelector(
export const selectResetPasswordState = createSelector(
selectAccountState,
(state: IAccountState) => state.forgotPassword
(state: IAccountState) => state.resetPassword
);
export const getForgotPasswordForm = createSelector(
selectForgotPasswordState,
fromForgotPassword.getForm
export const getResetPasswordForm = createSelector(
selectResetPasswordState,
fromResetPassword.getForm
);
export const getForgotPasswordHasStarted = createSelector(
selectForgotPasswordState,
fromForgotPassword.getHasStarted
export const getResetPasswordHasStarted = createSelector(
selectResetPasswordState,
fromResetPassword.getHasStarted
);
export const getForgotPasswordHasFinished = createSelector(
selectForgotPasswordState,
fromForgotPassword.getHasFinished
export const getResetPasswordHasFinished = createSelector(
selectResetPasswordState,
fromResetPassword.getHasFinished
);
export const getForgotPasswordErrorMessage = createSelector(
selectForgotPasswordState,
fromForgotPassword.getErrorMessage
export const getResetPasswordErrorMessage = createSelector(
selectResetPasswordState,
fromResetPassword.getErrorMessage
);
export const selectResetPasswordVerifyState = createSelector(
......
......@@ -33,17 +33,17 @@ import { ErrorReportingComponent } from "./error-reporting/error-reporting.compo
import { ErrorReportingContainer } from "./error-reporting/error-reporting.container";
import { ErrorReportingEffects } from "./error-reporting/error-reporting.effects";
import { BackupCodeComponent } from "./backup-code/backup-code.component";
import { ForgotPasswordComponent } from "./forgot-password/forgot-password.component";
import { ResetPasswordComponent } from "./reset-password/reset-password.component";
import { MarketingFrameComponent } from "./marketing-frame/marketing-frame.component";
import { ForgotPasswordContainer } from "./forgot-password/forgot-password.container";
import { ForgotPasswordEffects } from "./forgot-password/forgot-password.effects";
import { ResetPasswordVerifyComponent } from "./forgot-password/reset-password-verify/reset-password-verify.component";
import { ResetPasswordVerifyContainer } from "./forgot-password/reset-password-verify/reset-password-verify.container";
import { ResetPasswordVerifyEffects } from "./forgot-password/reset-password-verify/reset-password-verify.effects";
import { ResetPasswordContainer } from "./reset-password/reset-password.container";
import { ResetPasswordEffects } from "./reset-password/reset-password.effects";
import { ResetPasswordVerifyComponent } from "./reset-password/reset-password-verify/reset-password-verify.component";
import { ResetPasswordVerifyContainer } from "./reset-password/reset-password-verify/reset-password-verify.container";
import { ResetPasswordVerifyEffects } from "./reset-password/reset-password-verify/reset-password-verify.effects";
import { PasswordInputComponent } from "./change-password/password-input/password-input.component";
import { SetPasswordComponent } from "./forgot-password/set-password/set-password.component";
import { SetPasswordContainer } from "./forgot-password/set-password/set-password.container";
import { SetPasswordEffects } from "./forgot-password/set-password/set-password.effects";
import { SetPasswordComponent } from "./reset-password/set-password/set-password.component";
import { SetPasswordContainer } from "./reset-password/set-password/set-password.container";
import { SetPasswordEffects } from "./reset-password/set-password/set-password.effects";
export const COMPONENTS = [
AccountComponent,
......@@ -61,8 +61,8 @@ export const COMPONENTS = [
RegisterComponent,
RegisterContainer,
BackupCodeComponent,
ForgotPasswordComponent,
ForgotPasswordContainer,
ResetPasswordComponent,
ResetPasswordContainer,
ResetPasswordVerifyComponent,
ResetPasswordVerifyContainer,
SetPasswordComponent,
......@@ -89,7 +89,7 @@ export const SERVICES = [UserService, ConfirmEmailGuard];
RegisterEffects,
ConfirmEmailEffects,
ErrorReportingEffects,
ForgotPasswordEffects,
ResetPasswordEffects,
ResetPasswordVerifyEffects,
SetPasswordEffects
])
......
......@@ -23,7 +23,6 @@ import { BACKUP_CODE_CHARS, BACKUP_CODE_LENGTH } from "../constants";
export class ResetPasswordVerifyContainer implements OnInit {
form$ = this.store.select(fromAccount.getResetPasswordVerifyForm);
hasStarted$ = this.store.select(fromAccount.getResetPasswordVerifyHasStarted);
// hasFinished$ = this.store.select(fromAccount.getForgotPasswordHasFinished);
errorMessage$ = this.store.select(
fromAccount.getResetPasswordVerifyErrorMessage
);
......
......@@ -12,7 +12,7 @@ import {
ResetPasswordVerifyActionsUnion
} from "./reset-password-verify.actions";
const FORM_ID = "Forgot Password Form";
const FORM_ID = "Reset Password Form";
export interface IResetPasswordVerifyForm {
code: string;
......
import { Action } from "@ngrx/store";
export enum ForgotPasswordActionTypes {
SUBMIT_FORM = "[Forgot Password] Submit",
SUBMIT_FORM_SUCCESS = "[Forgot Password] Submit Success",
SUBMIT_FORM_FAILURE = "[Forgot Password] Submit Failure",
RESET_FORM = "[Forgot Password] Reset"
export enum ResetPasswordActionTypes {
SUBMIT_FORM = "[Reset Password] Submit",
SUBMIT_FORM_SUCCESS = "[Reset Password] Submit Success",
SUBMIT_FORM_FAILURE = "[Reset Password] Submit Failure",
RESET_FORM = "[Reset Password] Reset"
}
export class SubmitForm implements Action {
readonly type = ForgotPasswordActionTypes.SUBMIT_FORM;
readonly type = ResetPasswordActionTypes.SUBMIT_FORM;
}
export class SubmitFormSuccess implements Action {
readonly type = ForgotPasswordActionTypes.SUBMIT_FORM_SUCCESS;
readonly type = ResetPasswordActionTypes.SUBMIT_FORM_SUCCESS;
}
export class SubmitFormFailure implements Action {
readonly type = ForgotPasswordActionTypes.SUBMIT_FORM_FAILURE;
readonly type = ResetPasswordActionTypes.SUBMIT_FORM_FAILURE;
}
export class ResetForm implements Action {
readonly type = ForgotPasswordActionTypes.RESET_FORM;
readonly type = ResetPasswordActionTypes.RESET_FORM;
}
export type ForgotPasswordActionsUnion =
export type ResetPasswordActionsUnion =
| SubmitForm
| SubmitFormSuccess
| SubmitFormFailure
......
......@@ -6,25 +6,24 @@ import {
EventEmitter,
ViewChild,
ElementRef,
OnInit,
OnInit
} from "@angular/core";
import { FormGroupState } from "ngrx-forms";
import { IForgotPasswordForm } from "./forgot-password.reducer";
import { IResetPasswordForm } from "./reset-password.reducer";
@Component({
selector: "app-forgot-password",
templateUrl: "./forgot-password.component.html",
styleUrls: ["../account.component.scss", "./forgot-password.styles.scss"],
selector: "app-reset-password",
templateUrl: "./reset-password.component.html",
styleUrls: ["../account.component.scss", "./reset-password.styles.scss"],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ForgotPasswordComponent implements OnInit {
export class ResetPasswordComponent implements OnInit {
@Input()
isExtension: boolean;
@Input()
form: FormGroupState<IForgotPasswordForm>;
form: FormGroupState<IResetPasswordForm>;
@Input()
errorMessage: string;
@Input()
......@@ -55,6 +54,6 @@ export class ForgotPasswordComponent implements OnInit {
onReset() {
this.reset.emit();
setTimeout(() => (this.emailInput.nativeElement.focus()), 0);
setTimeout(() => this.emailInput.nativeElement.focus(), 0);
}
}
import { Component, ChangeDetectionStrategy } from "@angular/core";
import * as fromAccount from "../account.reducer";
import { Store } from "@ngrx/store";
import { SubmitForm, ResetForm } from "./forgot-password.actions";
import { SubmitForm, ResetForm } from "./reset-password.actions";
import { IS_EXTENSION } from "../../constants";
@Component({
template: `
<app-forgot-password
<app-reset-password
[form]="form$ | async"
[isExtension]="isExtension"
[hasStarted]="hasStarted$ | async"
......@@ -14,15 +14,15 @@ import { IS_EXTENSION } from "../../constants";
[errorMessage]="errorMessage$ | async"
(submitEmail)="submitEmail()"
(reset)="reset()"
></app-forgot-password>
></app-reset-password>
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ForgotPasswordContainer {
form$ = this.store.select(fromAccount.getForgotPasswordForm);
hasStarted$ = this.store.select(fromAccount.getForgotPasswordHasStarted);
hasFinished$ = this.store.select(fromAccount.getForgotPasswordHasFinished);
errorMessage$ = this.store.select(fromAccount.getForgotPasswordErrorMessage);
export class ResetPasswordContainer {
form$ = this.store.select(fromAccount.getResetPasswordForm);
hasStarted$ = this.store.select(fromAccount.getResetPasswordHasStarted);
hasFinished$ = this.store.select(fromAccount.getResetPasswordHasFinished);
errorMessage$ = this.store.select(fromAccount.getResetPasswordErrorMessage);
isExtension = IS_EXTENSION;
constructor(private store: Store<fromAccount.IAuthState>) {}
......
......@@ -2,28 +2,28 @@ import { Injectable } from "@angular/core";
import { Effect, Actions } from "@ngrx/effects";
import {
SubmitForm,
ForgotPasswordActionTypes,
ResetPasswordActionTypes,
SubmitFormSuccess,
SubmitFormFailure
} from "./forgot-password.actions";
} from "./reset-password.actions";
import { withLatestFrom, map, exhaustMap, catchError } from "rxjs/operators";
import { Store } from "@ngrx/store";
import { IState } from "../../app.reducers";
import { getForgotPasswordForm } from "../account.reducer";
import { getResetPasswordForm } from "../account.reducer";
import { UserService } from "../user";
import { of } from "rxjs";
@Injectable()
export class ForgotPasswordEffects {
export class ResetPasswordEffects {
@Effect()
submitForm$ = this.actions$
.ofType<SubmitForm>(ForgotPasswordActionTypes.SUBMIT_FORM)
.ofType<SubmitForm>(ResetPasswordActionTypes.SUBMIT_FORM)
.pipe(
withLatestFrom(this.store.select(getForgotPasswordForm)),
withLatestFrom(this.store.select(getResetPasswordForm)),
map(([action, form]) => form.value),
exhaustMap(form => {
const callForgotPassword = () => {
return this.userService.forgotPassword(form.email).pipe(
return this.userService.resetPassword(form.email).pipe(
map(() => new SubmitFormSuccess()),
catchError(err => of(new SubmitFormFailure()))
);
......
......@@ -9,68 +9,68 @@ import { required, pattern } from "ngrx-forms/validation";
import { IBaseFormState } from "../../utils/interfaces";
import {
ForgotPasswordActionsUnion,
ForgotPasswordActionTypes
} from "./forgot-password.actions";
ResetPasswordActionsUnion,
ResetPasswordActionTypes
} from "./reset-password.actions";
const FORM_ID = "Forgot Password Form";
const FORM_ID = "Reset Password Form";
export interface IForgotPasswordForm {
export interface IResetPasswordForm {
email: string;
showUrl: boolean;
url: string;
}
const validateAndUpdateFormState = updateGroup<IForgotPasswordForm>({
const validateAndUpdateFormState = updateGroup<IResetPasswordForm>({
email: validate(required, pattern(/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/))
});
export const initialFormState = validateAndUpdateFormState(
createFormGroupState<IForgotPasswordForm>(FORM_ID, {
createFormGroupState<IResetPasswordForm>(FORM_ID, {
email: "",
showUrl: false,
url: ""
})
);
export interface IForgotPasswordState extends IBaseFormState {
form: FormGroupState<IForgotPasswordForm>;
export interface IResetPasswordState extends IBaseFormState {
form: FormGroupState<IResetPasswordForm>;
errorMessage: string | null;
}
const initialState: IForgotPasswordState = {
const initialState: IResetPasswordState = {
form: initialFormState,
hasStarted: false,
hasFinished: false,
errorMessage: null
};
export const formReducer = createFormStateReducerWithUpdate<
IForgotPasswordForm
>(validateAndUpdateFormState);
export const formReducer = createFormStateReducerWithUpdate<IResetPasswordForm>(
validateAndUpdateFormState
);
export function reducer(
state = initialState,
action: ForgotPasswordActionsUnion
): IForgotPasswordState {
action: ResetPasswordActionsUnion
): IResetPasswordState {
const form = formReducer(state.form, action);
state = { ...state, form };
switch (action.type) {
case ForgotPasswordActionTypes.SUBMIT_FORM:
case ResetPasswordActionTypes.SUBMIT_FORM:
return {
...state,
hasStarted: true,
hasFinished: false
};
case ForgotPasswordActionTypes.SUBMIT_FORM_SUCCESS:
case ResetPasswordActionTypes.SUBMIT_FORM_SUCCESS:
return {
...state,
hasFinished: true
};
case ForgotPasswordActionTypes.SUBMIT_FORM_FAILURE:
case ResetPasswordActionTypes.SUBMIT_FORM_FAILURE:
return {
...state,
errorMessage: "An error occured",
......@@ -78,16 +78,15 @@ export function reducer(
hasStarted: false
};
case ForgotPasswordActionTypes.RESET_FORM:
case ResetPasswordActionTypes.RESET_FORM:
return initialState;
}
return state;
}
export const getForm = (state: IForgotPasswordState) => state.form;
export const getErrorMessage = (state: IForgotPasswordState) =>
export const getForm = (state: IResetPasswordState) => state.form;
export const getErrorMessage = (state: IResetPasswordState) =>
state.errorMessage;
export const getHasStarted = (state: IForgotPasswordState) => state.hasStarted;
export const getHasFinished = (state: IForgotPasswordState) =>
state.hasFinished;
export const getHasStarted = (state: IResetPasswordState) => state.hasStarted;
export const getHasFinished = (state: IResetPasswordState) => state.hasFinished;
......@@ -213,7 +213,7 @@ export class UserService {
});
}
public forgotPassword(email: string) {
public resetPassword(email: string) {
const url = this.sdk.formUrl("reset-password/");
const data = {
email
......@@ -320,7 +320,11 @@ export class UserService {
/** Final step of reset password process, set new password.
* Unlike change password, this doesn't require the old password.
*/
resetPasswordSetPassword(emailCode: string, newPassword: string, backupCode: string) {
resetPasswordSetPassword(
emailCode: string,
newPassword: string,
backupCode: string
) {
const newUserKeyPair = KeyPair.generate();
const { hash, salt } = hashPassword(newPassword);
......
......@@ -20,9 +20,9 @@ import { NoContentContainer } from "./no-content";
import { PopupLoggedInGuard } from "./guards/popup-logged-in.guard";
import { ConfirmEmailGuard } from "./account/confirm-email/confirm-email.guard";
import { ErrorReportingContainer } from "./account/error-reporting/error-reporting.container";
import { ForgotPasswordContainer } from "./account/forgot-password/forgot-password.container";
import { ResetPasswordVerifyContainer } from "./account/forgot-password/reset-password-verify/reset-password-verify.container";
import { SetPasswordContainer } from "./account/forgot-password/set-password/set-password.container";
import { ResetPasswordContainer } from "./account/reset-password/reset-password.container";
import { ResetPasswordVerifyContainer } from "./account/reset-password/reset-password-verify/reset-password-verify.container";
import { SetPasswordContainer } from "./account/reset-password/set-password/set-password.container";
/* tslint:disable:object-literal-sort-keys */
const appRoutes: Routes = [
......@@ -93,7 +93,7 @@ const appRoutes: Routes = [
},
{
path: "reset-password",
component: ForgotPasswordContainer,
component: ResetPasswordContainer,
canActivate: [AlreadyLoggedInGuard],
data: {
title: "Reset Password",
......
......@@ -7,22 +7,22 @@ import { StoreModule } from "@ngrx/store";
import { NgrxFormsModule } from "ngrx-forms";
import { BackupCodeComponent } from "../app/account/backup-code/backup-code.component";
import { ForgotPasswordComponent } from "../app/account/forgot-password/forgot-password.component";
import { ResetPasswordComponent } from "../app/account/reset-password/reset-password.component";
import { MarketingFrameComponent } from "../app/account/marketing-frame/marketing-frame.component";
import { FormLabelComponent } from "../app/shared/form-label/form-label.component";
import { LoginComponent } from "../app/account/login/login.component";
import { SharedModule } from "../app/shared";
import { ProgressIndicatorModule } from "../app/progress-indicator";
import * as fromForgotPassword from "../app/account/forgot-password/forgot-password.reducer";
import * as fromResetPassword from "../app/account/reset-password/reset-password.reducer";
import * as fromLogin from "../app/account/login/login.reducer";
import * as fromChangePassword from "../app/account/change-password/change-password.reducer";
import * as fromSetPassword from "../app/account/forgot-password/set-password/set-password.reducer";
import * as fromResetPasswordVerify from "../app/account/forgot-password/reset-password-verify/reset-password-verify.reducer";
import * as fromSetPassword from "../app/account/reset-password/set-password/set-password.reducer";
import * as fromResetPasswordVerify from "../app/account/reset-password/reset-password-verify/reset-password-verify.reducer";
import { RouterTestingModule } from "@angular/router/testing";
import { ChangePasswordComponent } from "../app/account/change-password";
import { PasswordInputComponent } from "../app/account/change-password/password-input/password-input.component";
import { SetPasswordComponent } from "../app/account/forgot-password/set-password/set-password.component";
import { ResetPasswordVerifyComponent } from "../app/account/forgot-password/reset-password-verify/reset-password-verify.component";
import { SetPasswordComponent } from "../app/account/reset-password/set-password/set-password.component";
import { ResetPasswordVerifyComponent } from "../app/account/reset-password/reset-password-verify/reset-password-verify.component";
storiesOf("Account", module)
.addDecorator(withKnobs)
......@@ -46,13 +46,13 @@ storiesOf("Account", module)
code: "CBVDCH4G23MJ46FXJBR8GDX4WKBF97VR"
}
}))
.add("Forgot Password", () => ({
component: ForgotPasswordComponent,
.add("Reset Password", () => ({
component: ResetPasswordComponent,
props: {
isExtension: boolean("isExtension", true),
hasStarted: boolean("hasStarted", false),
hasFinished: boolean("hasFinished", false),
form: fromForgotPassword.initialFormState
form: fromResetPassword.initialFormState
}
}))
.add("Reset Password Verify", () => ({
......@@ -68,32 +68,33 @@ storiesOf("Account", module)
.add("Form Label", () => {
const defaultFormLabelState = "active";
const formLabelControls = {
Default: defaultFormLabelState,
Inactive: "inactive",
Complete: "complete",
Default: defaultFormLabelState,
Inactive: "inactive",
Complete: "complete"
};
// any type is, I think, because storybook is 4.0 but types aren't
const formLabelControl: any = select(
'Label State',
formLabelControls,
defaultFormLabelState,
"Label State",
formLabelControls,
defaultFormLabelState
);
// If I don't do something like this, I get an error about
// FormLabelComponent being declared but not used
if (FormLabelComponent.name === '') {}
if (FormLabelComponent.name === "") {
}
return {
template: `
<app-form-label
for="nothing"
[isLarge]="${boolean('Is Large', true)}"
[isInactive]="${formLabelControl === 'inactive' ? true : false}"
[isComplete]="${formLabelControl === 'complete' ? true : false}"
[isLarge]="${boolean("Is Large", true)}"
[isInactive]="${formLabelControl === "inactive" ? true : false}"
[isComplete]="${formLabelControl === "complete" ? true : false}"
>
${text("Label text", "Password")}
</app-form-label>
`,
`
};
})
.add("Login", () => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment