You've already forked openaccounting-web
forked from cybercinch/openaccounting-web
log in automatically after clicking verify link
This commit is contained in:
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { Router, ActivatedRoute } from '@angular/router';
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { AppError } from '../shared/error';
|
import { AppError } from '../shared/error';
|
||||||
import { UserService } from '../core/user.service';
|
import { UserService } from '../core/user.service';
|
||||||
|
import { SessionService } from '../core/session.service';
|
||||||
|
import { Util } from '../shared/util';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -15,16 +17,22 @@ export class VerifyUserPage {
|
|||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private userService: UserService
|
private userService: UserService,
|
||||||
|
private sessionService: SessionService
|
||||||
) {
|
) {
|
||||||
|
let code = null;
|
||||||
|
|
||||||
this.route.queryParams.switchMap(params => {
|
this.route.queryParams.switchMap(params => {
|
||||||
let code = params['code'];
|
code = params['code'];
|
||||||
|
|
||||||
if(!code) {
|
if(!code) {
|
||||||
throw new Error('Missing code');
|
throw new Error('Missing code');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.userService.verifyUser(code);
|
return this.userService.verifyUser(code);
|
||||||
|
}).switchMap(() => {
|
||||||
|
let sessionId = Util.newGuid();
|
||||||
|
return this.sessionService.login(code, '', sessionId);
|
||||||
}).subscribe(() => {
|
}).subscribe(() => {
|
||||||
this.success = true;
|
this.success = true;
|
||||||
}, err => {
|
}, err => {
|
||||||
|
|||||||
Reference in New Issue
Block a user