Aktualisierung der GroupOfUser-, User- und UserRep-Controller. Aktualisieren Sie Agular-Referenzen und entfernen Sie Konsolenprotokolle.
This commit is contained in:
@@ -59,7 +59,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Ok(await _service.HasGroup(username, groupname));
|
return await _service.HasGroup(username, groupname).ThenAsync(Ok, (m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using DigitalData.UserManager.Application.DTOs.User;
|
|||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DigitalData.UserManager.API.Controllers
|
namespace DigitalData.UserManager.API.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.UserRep;
|
using DigitalData.UserManager.Application.DTOs.UserRep;
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
@@ -26,14 +27,12 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.ReadAllAsync(withUser, withRepGroup, withRightGroup, withRepUser, userId);
|
return await _service.ReadAllAsync(withUser, withRepGroup, withRightGroup, withRepUser, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
}
|
return NotFound();
|
||||||
|
});
|
||||||
return NotFound(result);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { Observable, of } from 'rxjs';
|
|||||||
import { AuthenticationService } from '../services/authentication.service'; // Adjust the path as necessary
|
import { AuthenticationService } from '../services/authentication.service'; // Adjust the path as necessary
|
||||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { LoginComponent } from '../login/login.component';
|
import { LoginComponent } from '../login/login.component';
|
||||||
import Swal from 'sweetalert2';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -47,4 +46,4 @@ export class AuthGuard implements CanActivate {
|
|||||||
});
|
});
|
||||||
return dialogRef;
|
return dialogRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||||
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType } from '@generic-ui/ngx-grid';
|
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType } from '@generic-ui/ngx-grid';
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { GroupService } from 'src/app/services/group.service';
|
import { GroupService } from '../../services/group.service';
|
||||||
import { forkJoin, of } from 'rxjs';
|
import { Observable, forkJoin, of } from 'rxjs';
|
||||||
import { catchError, finalize } from 'rxjs/operators';
|
import { catchError, finalize } from 'rxjs/operators';
|
||||||
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
||||||
|
import { DirGroupService } from '../../services/dir-group.service';
|
||||||
|
import { DirGroup } from '../../models/user-management.api.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-dir-import',
|
selector: 'app-group-dir-import',
|
||||||
@@ -40,15 +42,12 @@ export class GroupDirImportComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addSelectedGroups() {
|
addSelectedGroups() {
|
||||||
let requests = [];
|
let requests = new Array<Observable<DirGroup | null>>();
|
||||||
let numAdded: number = 0;
|
let numAdded: number = 0;
|
||||||
for (let row of this.dirGroups.selectedRows) {
|
for (let row of this.dirGroups.selectedRows) {
|
||||||
// Create an Observable for each request and add it to the requests array
|
|
||||||
requests.push(
|
requests.push(
|
||||||
this.gService.createByDir({ samaccountname: row?.source?.samaccountname }).pipe(
|
this.gService.createByDir({ samaccountname: row?.source?.samaccountname }).pipe(
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
console.log(err);
|
|
||||||
// In case of error, return a 'null' observable for this request, so it doesn't affect other requests
|
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -72,13 +71,9 @@ export class GroupDirImportComponent implements OnInit, AfterViewInit {
|
|||||||
})
|
})
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: (results) => {
|
next: (results) => {
|
||||||
// Increment numAdded for each successful request
|
|
||||||
// You can increment numAdded for each result that is not null
|
|
||||||
numAdded += results.filter(result => result !== null).length;
|
numAdded += results.filter(result => result !== null).length;
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
// You may need to handle any potential errors here
|
|
||||||
console.log('An error occurred', err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { AfterViewInit, Component, Inject, Input, OnDestroy, OnInit, ViewChild,
|
|||||||
import { ApiService } from '../../../services/user-management.api.service';
|
import { ApiService } from '../../../services/user-management.api.service';
|
||||||
import { GuiColumn, GuiColumnMenu, GuiSorting, GuiRowDetail, GuiPaging, GuiPagingDisplay, GuiSearching, GuiCellEdit, GuiInfoPanel, GuiTitlePanel, GuiRowSelection, GuiSelectedRow, GuiGridComponent, GuiGridApi, GuiTheme } from '@generic-ui/ngx-grid';
|
import { GuiColumn, GuiColumnMenu, GuiSorting, GuiRowDetail, GuiPaging, GuiPagingDisplay, GuiSearching, GuiCellEdit, GuiInfoPanel, GuiTitlePanel, GuiRowSelection, GuiSelectedRow, GuiGridComponent, GuiGridApi, GuiTheme } from '@generic-ui/ngx-grid';
|
||||||
import { Subscription } from 'rxjs/internal/Subscription';
|
import { Subscription } from 'rxjs/internal/Subscription';
|
||||||
import { ColorModeService, Theme } from 'src/app/services/color-mode.service';
|
import { ColorModeService, Theme } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-base-table',
|
selector: 'app-base-table',
|
||||||
@@ -154,8 +154,7 @@ export class BaseTableComponent<TModel, TApiService extends ApiService<TModel>>
|
|||||||
this.source = response;
|
this.source = response;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
error: (error) => console.error('Error fetching users:', error)
|
error: (error) => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
import { Component, Inject } from '@angular/core';
|
||||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||||
import { DirGroupService } from 'src/app/services/dir-group.service';
|
import { DirGroupService } from '../../../services/dir-group.service';
|
||||||
import { DirGroup } from 'src/app/models/user-management.api.models';
|
import { DirGroup } from '../../../models/user-management.api.models';
|
||||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
import { ColorModeService } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dir-group-table',
|
selector: 'app-dir-group-table',
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
import { Component, Inject } from '@angular/core';
|
||||||
import { DirUser } from 'src/app/models/user-management.api.models';
|
import { DirUser } from '../../../models/user-management.api.models';
|
||||||
import { DirUserService } from 'src/app/services/dir-user.service';
|
import { DirUserService } from '../../../services/dir-user.service';
|
||||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||||
import { GuiColumn } from '@generic-ui/ngx-grid/gui/grid/src/core/api/gui.grid.public-api';
|
import { GuiColumn } from '@generic-ui/ngx-grid/gui/grid/src/core/api/gui.grid.public-api';
|
||||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
import { ColorModeService } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dir-user-table',
|
selector: 'app-dir-user-table',
|
||||||
@@ -21,7 +21,7 @@ export class DirUserTableComponent extends BaseTableComponent<DirUser, DirUserSe
|
|||||||
this.source = response;
|
this.source = response;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
error: (error: any) => console.error('Error fetching users:', error)
|
error: (error: any) => {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ import { GroupService } from '../../../services/group.service';
|
|||||||
import { Group } from '../../../models/user-management.api.models';
|
import { Group } from '../../../models/user-management.api.models';
|
||||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
import { ColorModeService } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-table',
|
selector: 'app-group-table',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { GroupOfUserService } from '../../../services/group-of-user.service';
|
|||||||
import { GroupOfUser } from '../../../models/user-management.api.models';
|
import { GroupOfUser } from '../../../models/user-management.api.models';
|
||||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
import { ColorModeService } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-user-table',
|
selector: 'app-group-user-table',
|
||||||
@@ -22,7 +22,7 @@ export class GroupUserTableComponent extends BaseTableComponent<GroupOfUser, Gro
|
|||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.source = response;
|
this.source = response;
|
||||||
},
|
},
|
||||||
error: (error) => console.error('Error fetching users:', error)
|
error: (error) => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ import { Module } from '../../../models/user-management.api.models';
|
|||||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||||
import { ModuleService } from '../../../services/module.service'
|
import { ModuleService } from '../../../services/module.service'
|
||||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
import { ColorModeService } from '../../../services/color-mode.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-module-table',
|
selector: 'app-module-table',
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ export class UserRepTableComponent extends BaseTableComponent<UserRep, UserRepSe
|
|||||||
|
|
||||||
override fetchData(userId?: number): void {
|
override fetchData(userId?: number): void {
|
||||||
this.service.getAll(false, true, true, true, userId).subscribe({
|
this.service.getAll(false, true, true, true, userId).subscribe({
|
||||||
next: (response: any) => {
|
next: (response: UserRep[]) => {
|
||||||
this.source = response;
|
this.source = response;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
error: (error: any) => console.error('Error fetching users:', error)
|
error: (error: any) => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,11 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
|||||||
mosService: ModuleOfUserService;
|
mosService: ModuleOfUserService;
|
||||||
gosService: GroupOfUserService;
|
gosService: GroupOfUserService;
|
||||||
|
|
||||||
constructor(mosService: ModuleOfUserService, gosService: GroupOfUserService, service: UserService, @Inject('USER_TABLE_COLUMNS') columns: Array<GuiColumn>, cModeService: ColorModeService) {
|
constructor(mosService: ModuleOfUserService,
|
||||||
|
gosService: GroupOfUserService,
|
||||||
|
service: UserService,
|
||||||
|
@Inject('USER_TABLE_COLUMNS') columns: Array<GuiColumn>,
|
||||||
|
cModeService: ColorModeService) {
|
||||||
super(service, columns, cModeService)
|
super(service, columns, cModeService)
|
||||||
this.mosService = mosService;
|
this.mosService = mosService;
|
||||||
this.gosService = gosService;
|
this.gosService = gosService;
|
||||||
@@ -28,7 +32,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
|||||||
next: (users) => {
|
next: (users) => {
|
||||||
this.source = users;
|
this.source = users;
|
||||||
},
|
},
|
||||||
error: (error) => console.error('Error fetching users:', error)
|
error: (error) => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +41,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
|||||||
next: (users) => {
|
next: (users) => {
|
||||||
this.source = users;
|
this.source = users;
|
||||||
},
|
},
|
||||||
error: (error) => console.error('Error fetching users:', error)
|
error: (error) => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,13 +68,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const responses = await Promise.all(deletionPromises);
|
const responses = await Promise.all(deletionPromises);
|
||||||
responses.forEach(response => {
|
|
||||||
if (!response?.isSuccess) {
|
|
||||||
console.error(response?.messages);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting module of users:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +79,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const responses = await Promise.all(deletionPromises);
|
const responses = await Promise.all(deletionPromises);
|
||||||
responses.forEach(response => {
|
|
||||||
if (!response?.isSuccess) {
|
|
||||||
console.error(response?.messages);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting group of users:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||||
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType, GuiSelectedRow } from '@generic-ui/ngx-grid';
|
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType, GuiSelectedRow } from '@generic-ui/ngx-grid';
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { GroupService } from 'src/app/services/group.service';
|
import { GroupService } from '../../services/group.service';
|
||||||
import { forkJoin, of } from 'rxjs';
|
import { Observable, forkJoin, of } from 'rxjs';
|
||||||
import { catchError, finalize } from 'rxjs/operators';
|
import { catchError, finalize } from 'rxjs/operators';
|
||||||
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
||||||
import { DirUserTableComponent } from '../tables/dir-user-table/dir-user-table.component';
|
import { DirUserTableComponent } from '../tables/dir-user-table/dir-user-table.component';
|
||||||
import { UserService } from 'src/app/services/user.service';
|
import { UserService } from '../../services/user.service';
|
||||||
|
import {User} from '../../models/user-management.api.models'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-group-dir-import',
|
selector: 'app-user-group-dir-import',
|
||||||
@@ -43,10 +44,9 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addSelectedUsers() {
|
addSelectedUsers() {
|
||||||
let requests = [];
|
let requests = new Array<Observable<User | null>>();
|
||||||
let numAdded: number = 0;
|
let numAdded: number = 0;
|
||||||
for (let row of this.dirUsers.selectedRows) {
|
for (let row of this.dirUsers.selectedRows) {
|
||||||
console.log(row)
|
|
||||||
// Create an Observable for each request and add it to the requests array
|
// Create an Observable for each request and add it to the requests array
|
||||||
requests.push(
|
requests.push(
|
||||||
this.uService.create({
|
this.uService.create({
|
||||||
@@ -56,8 +56,6 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
|||||||
name: row.source?.sn?.[0],
|
name: row.source?.sn?.[0],
|
||||||
}).pipe(
|
}).pipe(
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
console.log('An error occurred', err);
|
|
||||||
// In case of error, return a 'null' observable for this request, so it doesn't affect other requests
|
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -81,13 +79,9 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
|||||||
})
|
})
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: (results) => {
|
next: (results) => {
|
||||||
// Increment numAdded for each successful request
|
|
||||||
// You can increment numAdded for each result that is not null
|
|
||||||
numAdded += results.filter(result => result !== null).length;
|
numAdded += results.filter(result => result !== null).length;
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
// You may need to handle any potential errors here
|
|
||||||
console.log('An error occurred', err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { GuiColumn, GuiSelectedRow } from '@generic-ui/ngx-grid/gui/grid/src/cor
|
|||||||
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
||||||
import { UserRepTableComponent } from '../tables/user-rep-table/user-rep-table.component';
|
import { UserRepTableComponent } from '../tables/user-rep-table/user-rep-table.component';
|
||||||
import { GroupTableComponent } from '../tables/group-table/group-table.component';
|
import { GroupTableComponent } from '../tables/group-table/group-table.component';
|
||||||
import { UserRepService } from 'src/app/services/user-representation.service';
|
import { UserRepService } from '../../services/user-representation.service';
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -12,12 +12,9 @@ export class UserComponent {
|
|||||||
cellEditing: GuiCellEdit = {
|
cellEditing: GuiCellEdit = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
rowEdit: (value: any, item: any, index: number) => {
|
rowEdit: (value: any, item: any, index: number) => {
|
||||||
console.log("rowEdit", value, item, index)
|
|
||||||
console.log(this.userTable.selectedRows)
|
|
||||||
return Boolean(index % 2);
|
return Boolean(index % 2);
|
||||||
},
|
},
|
||||||
cellEdit: (value: any, item: any, index: number) => {
|
cellEdit: (value: any, item: any, index: number) => {
|
||||||
console.log("cellEdit", value, item, index)
|
|
||||||
return Boolean(index % 5);
|
return Boolean(index % 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,8 +76,4 @@ export interface DirUser {
|
|||||||
sn?: Array<string>;
|
sn?: Array<string>;
|
||||||
mail?: string;
|
mail?: string;
|
||||||
addedWho?: string;
|
addedWho?: string;
|
||||||
}
|
|
||||||
|
|
||||||
export interface AuthCheckDto {
|
|
||||||
isAuthenticated: boolean;
|
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,6 @@ export class NavMenuComponent {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.error("unexpected err happend", err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { AuthCheckDto } from '../models/user-management.api.models';
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
|
|
||||||
@@ -9,15 +8,20 @@ import Swal from 'sweetalert2';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class AuthenticationService {
|
export class AuthenticationService {
|
||||||
constructor(private router: Router, private http: HttpClient, @Inject('LOGIN_URL') private loginUrl: string, @Inject('LOGOUT_URL') private logoutUrl: string, @Inject('LOGIN_CHECK_URL') private checkUrl: string) { }
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
private http: HttpClient,
|
||||||
|
@Inject('LOGIN_URL') private loginUrl: string,
|
||||||
|
@Inject('LOGOUT_URL') private logoutUrl: string,
|
||||||
|
@Inject('LOGIN_CHECK_URL') private checkUrl: string) { }
|
||||||
|
|
||||||
isAuthenticated(): Observable<boolean> {
|
isAuthenticated(): Observable<boolean> {
|
||||||
return new Observable(observer => {
|
return new Observable(observer => {
|
||||||
this.http.get<AuthCheckDto>(this.checkUrl, { withCredentials: true })
|
this.http.get<boolean>(this.checkUrl, { withCredentials: true })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
_isLogedIn = response.isAuthenticated;
|
_isLogedIn = response;
|
||||||
observer.next(response.isAuthenticated)
|
observer.next(response)
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
this.showErrorAlert()
|
this.showErrorAlert()
|
||||||
@@ -54,11 +58,9 @@ export class AuthenticationService {
|
|||||||
this.http.post<any>(this.logoutUrl, {}, { withCredentials: true })
|
this.http.post<any>(this.logoutUrl, {}, { withCredentials: true })
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
if (response.ok) {
|
this.router.navigate(['/']);
|
||||||
this.router.navigate(['/']);
|
_isLogedIn = false;
|
||||||
_isLogedIn = false;
|
observer.next(response)
|
||||||
observer.next(response)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: (error) => observer.error(error),
|
error: (error) => observer.error(error),
|
||||||
complete: () => observer.complete()
|
complete: () => observer.complete()
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ export class UserService extends ApiService<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createByDir(createModel: DirUser): Observable<DirUser> {
|
createByDir(createModel: DirUser): Observable<DirUser> {
|
||||||
console.log(createModel)
|
|
||||||
return this.http.post<DirUser>(`${this.baseUrl}/byDir`, createModel, { withCredentials: true });
|
return this.http.post<DirUser>(`${this.baseUrl}/byDir`, createModel, { withCredentials: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,4 +184,4 @@ if (environment.production) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
platformBrowserDynamic(providers).bootstrapModule(AppModule)
|
platformBrowserDynamic(providers).bootstrapModule(AppModule)
|
||||||
.catch(err => console.log(err));
|
.catch(err => {});
|
||||||
|
|||||||
Reference in New Issue
Block a user