in src/components/users/signin/ko/runtime/signin.ts [102:160]
public async signin(): Promise<void> {
this.errorMessages([]);
const validationGroup = {
username: this.username,
password: this.password
};
const result = validation.group(validationGroup);
const clientErrors = result();
if (clientErrors.length > 0) {
result.showAllMessages();
dispatchErrors(this.eventManager, ErrorSources.signin, clientErrors);
this.errorMessages(clientErrors);
return;
}
try {
this.working(true);
await this.usersService.signInWithBasic(this.username(), this.password());
const clientReturnUrl = sessionStorage.getItem("returnUrl");
const returnUrl = this.routeHelper.getQueryParameter("returnUrl") || clientReturnUrl;
if (returnUrl) {
await this.router.navigateTo(Utils.sanitizeReturnUrl(returnUrl));
return;
}
this.navigateToHome(); // default redirect
}
catch (error) {
if (error instanceof MapiError) {
if (error.code === "identity_not_confirmed") {
const msg = [`We found an unconfirmed account for the e-mail address ${this.username()}. To complete the creation of your account we need to verify your e-mail address. We’ve sent an e-mail to ${this.username()}. Please follow the instructions inside the e-mail to activate your account. If the e-mail doesn’t arrive within the next few minutes, please check your junk email folder`];
dispatchErrors(this.eventManager, ErrorSources.signin, msg);
return;
}
this.errorMessages([error.message]);
dispatchErrors(this.eventManager, ErrorSources.signin, [error.message]);
return;
}
if (error instanceof UnauthorizedError) {
this.errorMessages([error.message]);
dispatchErrors(this.eventManager, ErrorSources.signin, [error.message]);
return;
}
throw new Error(`Unable to complete signing in. Error: ${error.message}`);
}
finally {
this.working(false);
}
}