Files
maptology/web-angular/src/app/views/activate.component.ts
T
Marcus Handte 85c026fa8f
LocationBasedServices/maptology/pipeline/head This commit looks good
Upgrade gradle, plugins, android dependencies and angular code generator.
Upgrade gralde to latest version recommended by android studio.
Remove outdated android options in gradle properties.
Upgrade outdated gradle plugins to support npm downloads.
Upgrade android app dependencies to latest versions.
Make logger service constants static final.
Replace angular client generator with swagger codegen.
Adapt angular code to new client.
Integrate proxy config and basehref into angular cli configuration.
Change jenkinsfile to only deploy releases.
Change jenkinsfile to use gradle wrapper instead of fixed version.
Remove dots from user emails to not confuse simple email clients.
2020-06-20 10:28:43 +02:00

65 lines
2.5 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { DefaultService } from '../api';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { ResourceService } from '../services/resource.service';
@Component({
selector: 'app-activate',
templateUrl: './activate.component.html'
})
export class ActivateComponent implements OnInit {
showMessage = true;
constructor(
public res: ResourceService,
private apiClientService: DefaultService,
private dialog: MatDialog,
private router: Router,
private route: ActivatedRoute) { }
ngOnInit(): void {
const token = this.route.snapshot.paramMap.get('token');
if (!token) {
this.router.navigate(['/']);
} else {
this.apiClientService.verifyUserEmail(token).subscribe((result) => {
this.showMessage = false;
MessageDialogComponent.open(this.dialog, {
title: this.res.strings('activate_success_title'),
message: this.res.strings('activate_success_message'),
button: this.res.strings('button_gotit')}).subscribe((close) => {
this.router.navigate(['/']);
});
}, (error) => {
this.showMessage = false;
let message: string = this.res.strings('activate_error_message');
if (error instanceof HttpErrorResponse) {
switch (error.status) {
case HttpStatusCode.BAD_REQUEST:
message = this.res.strings('activate_error_badlink');
break;
case HttpStatusCode.FORBIDDEN:
message = this.res.strings('activate_error_expiredlink');
break;
default:
break;
}
}
MessageDialogComponent.open(this.dialog, {
title: this.res.strings('activate_error_title'),
message: message,
button: this.res.strings('button_gotit') }).subscribe((close) => {
this.router.navigate(['/']);
});
});
}
}
}