Create Users Manually (Email still required) (#1381)
* Implemented a manual button to allow users to setup an account, even after they invited. Updated error toast to put "Error" in the title of the toast. * Updated the exception middleware to always send full context instead of generic "Internal Server Error"
This commit is contained in:
parent
63d74ecf9a
commit
1d806bf622
10 changed files with 1668 additions and 17 deletions
|
@ -85,9 +85,9 @@ export class ErrorInterceptor implements HttpInterceptor {
|
|||
this.toastr.error('There was an issue downloading this file or you do not have permissions', error.status);
|
||||
return;
|
||||
}
|
||||
this.toastr.error(error.error, error.status);
|
||||
this.toastr.error(error.error, error.status + ' Error');
|
||||
} else {
|
||||
this.toastr.error(error.statusText === 'OK' ? error.error : error.statusText, error.status);
|
||||
this.toastr.error(error.statusText === 'OK' ? error.error : error.statusText, error.status + ' Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,15 @@ export class AccountService implements OnDestroy {
|
|||
return this.httpClient.post<User>(this.baseUrl + 'account/confirm-email', model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a user id, returns a full url for setting up the user account
|
||||
* @param userId
|
||||
* @returns
|
||||
*/
|
||||
getInviteUrl(userId: number, withBaseUrl: boolean = true) {
|
||||
return this.httpClient.get<string>(this.baseUrl + 'account/invite-url?userId=' + userId + '&withBaseUrl=' + withBaseUrl, {responseType: 'text' as 'json'});
|
||||
}
|
||||
|
||||
getDecodedToken(token: string) {
|
||||
return JSON.parse(atob(token.split('.')[1]));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
<span id="member-name--{{idx}}">{{invite.username | titlecase}} </span>
|
||||
<div class="float-end">
|
||||
<button class="btn btn-danger btn-sm me-2" (click)="deleteUser(invite)">Cancel</button>
|
||||
<button class="btn btn-secondary btn-sm" (click)="resendEmail(invite)">Resend</button>
|
||||
<button class="btn btn-secondary btn-sm me-2" (click)="resendEmail(invite)">Resend</button>
|
||||
<button class="btn btn-secondary btn-sm" (click)="setup(invite)">Setup</button>
|
||||
</div>
|
||||
</h4>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { catchError, take } from 'rxjs/operators';
|
||||
import { MemberService } from 'src/app/_services/member.service';
|
||||
import { Member } from 'src/app/_models/member';
|
||||
import { User } from 'src/app/_models/user';
|
||||
|
@ -13,6 +13,7 @@ import { MessageHubService } from 'src/app/_services/message-hub.service';
|
|||
import { InviteUserComponent } from '../invite-user/invite-user.component';
|
||||
import { EditUserComponent } from '../edit-user/edit-user.component';
|
||||
import { ServerService } from 'src/app/_services/server.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-users',
|
||||
|
@ -34,7 +35,8 @@ export class ManageUsersComponent implements OnInit, OnDestroy {
|
|||
private toastr: ToastrService,
|
||||
private confirmService: ConfirmService,
|
||||
public messageHub: MessageHubService,
|
||||
private serverService: ServerService) {
|
||||
private serverService: ServerService,
|
||||
private router: Router) {
|
||||
this.accountService.currentUser$.pipe(take(1)).subscribe((user) => {
|
||||
if (user) {
|
||||
this.loggedInUsername = user.username;
|
||||
|
@ -122,7 +124,6 @@ export class ManageUsersComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
resendEmail(member: Member) {
|
||||
|
||||
this.serverService.isServerAccessible().subscribe(canAccess => {
|
||||
this.accountService.resendConfirmationEmail(member.id).subscribe(async (email) => {
|
||||
if (canAccess) {
|
||||
|
@ -134,7 +135,15 @@ export class ManageUsersComponent implements OnInit, OnDestroy {
|
|||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setup(member: Member) {
|
||||
this.accountService.getInviteUrl(member.id, false).subscribe(url => {
|
||||
console.log('Url: ', url);
|
||||
if (url) {
|
||||
this.router.navigateByUrl(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updatePassword(member: Member) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue