Skip to content

Commit

Permalink
feat(account): Allows resending of alt email validation
Browse files Browse the repository at this point in the history
If alt email is changed, resend validation email

Fixes runbox#1510
  • Loading branch information
castaway committed Nov 11, 2024
1 parent 8142db4 commit 4a7b911
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/account-app/account-app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h3 class="sideNavHeader">Settings Menu</h3>
</mat-expansion-panel-header>
<mat-list-item routerLink="/account/details">
<p mat-line>
<mat-icon mat-list-icon svgIcon="face"></mat-icon> <span>Personal Details</span>
<mat-icon mat-list-icon svgIcon="face-man"></mat-icon> <span>Personal Details</span>
</p>
</mat-list-item>
<mat-list-item routerLink="/account/storage">
Expand Down
1 change: 1 addition & 0 deletions src/app/account-details/personal-details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ <h3><strong>Address details</strong></h3>
</div>
<div class="action-buttons">
<button mat-raised-button color="primary" (click)="update()">Save Details</button>
<button *ngIf="!is_alternative_email_validated" mat-raised-button color="primary" (click)="validate_alt_email()">Resend Alternative Email Validation</button>
</div>
</form>
</div>
Expand Down
16 changes: 14 additions & 2 deletions src/app/account-details/personal-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class PersonalDetailsComponent {
modal_password_ref;

details: Subject<AccountDetailsInterface> = new Subject();
is_alternative_email_validated = true;

selectedCountry: any;
selectedTimezone: any;
Expand All @@ -60,6 +61,7 @@ export class PersonalDetailsComponent {
) {
this.details.subscribe((details: AccountDetailsInterface) => {
this.detailsForm.patchValue(details);
this.is_alternative_email_validated = details.email_alternative_status === 0;
});

this.loadDetails();
Expand Down Expand Up @@ -158,10 +160,20 @@ export class PersonalDetailsComponent {
.post('/rest/v1/account/details', updates)
.pipe(map((res: HttpResponse<any>) => res['result']))
.subscribe((details) => {
this.details.next(details);
if(details && details.email_alternative) {
this.details.next(details);
this.rmm.show_error('Account details updated', 'Dismiss');
} else {
this.rmm.show_error('Failed to update details', 'Dismiss');
}
});
}

this.rmm.show_error('Account details updated', 'Dismiss');
public validate_alt_email() {
this.http.post('/rest/v1/account/alt_email_validation', {})
.subscribe((res) => {
this.rmm.show_error('Validation email resent', 'Dismiss');
});;
}

show_modal_password() {
Expand Down
3 changes: 3 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<p *ngIf="experimentalFeatureEnabled">
<a routerLink="/onscreen" class="textLink"> (Experimental) create a video call </a>
</p>
<p *ngIf="(rmmapi.me | async)?.is_alternative_email_validated">
<span style="color:red">Please confirm your Alternative Email address</span> <a routerLink="/account/details">Visit the Account Details page to resend the email</a>
</p>
</div>
<div>
<button mat-icon-button [matMenuTriggerFor]="settingsMenu" id="webmailSettingsMenuButton" matTooltip="Show webmail settings">
Expand Down
1 change: 1 addition & 0 deletions src/app/rmm/account-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface AccountDetailsInterface {
first_name: string;
last_name: string;
email_alternative: string;
email_alternative_status: number;
phone_number: number;
company: string;
org_number: number;
Expand Down
1 change: 1 addition & 0 deletions src/app/welcome/welcomedesk.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<h1>Congratulations -- your new Runbox account is ready!</h1>
<div *ngIf="postSignup == 'offer'" id="introSpecialOffer">
<h3>Take advantage of our current 20% discount by proceeding to <a routerLink="/account/plans">Plans & Upgrades</a> below.</h3>
<h4 *ngIf="!me.is_alternative_email_validated">Please validate your alternative email addressm, <a routerLink="/account/details">Visit the Account Details page to resend the email</a>.</h4>
<h4> You can also <a routerLink="/welcome">continue setting up your account</a>, or go <a routerLink="/">straight to your Inbox</a>.</h4>
<br />
<a routerLink="/account/plans">
Expand Down
6 changes: 5 additions & 1 deletion src/app/welcome/welcomedesk.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// ---------- END RUNBOX LICENSE ----------

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RunboxWebmailAPI } from '../rmmapi/rbwebmail';
import { WelcomeDeskComponent } from './welcomedesk.component';
import { ActivatedRoute, Router, convertToParamMap } from '@angular/router';
import { of } from 'rxjs';
Expand All @@ -37,8 +38,11 @@ describe('WelcomeDeskComponent', () => {
provide: ActivatedRoute,
useValue: {
queryParams: of(convertToParamMap({offer: 'y'}))
}
},
},
{ provide: RunboxWebmailAPI, useValue: {
me: of({first_name: 'Test', last_name: 'User'}),
}, }
]
})
.compileComponents();
Expand Down
7 changes: 6 additions & 1 deletion src/app/welcome/welcomedesk.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { RunboxMe, RunboxWebmailAPI } from '../rmmapi/rbwebmail';

@Component({
selector: 'app-welcome',
Expand All @@ -27,10 +28,14 @@ import { ActivatedRoute } from '@angular/router';
})

export class WelcomeDeskComponent implements OnInit {
public me: RunboxMe;

constructor(
private activatedRoute: ActivatedRoute,
) { }
public rmmapi: RunboxWebmailAPI
) {
this.rmmapi.me.subscribe(me => this.me = me);
}

public postSignup = ''

Expand Down

0 comments on commit 4a7b911

Please sign in to comment.