weedkeeper changes
This commit is contained in:
parent
785e1e464f
commit
dc22f1b045
@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { AuthService } from "./core/services/auth.service";
|
import { AuthService } from "./core/auth/services/auth.service";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@ -10,6 +10,9 @@ import { SharedModule } from "./shared/shared.module";
|
|||||||
import { CoreModule } from "./core/core.module";
|
import { CoreModule } from "./core/core.module";
|
||||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||||
import { DatePipe } from "@angular/common";
|
import { DatePipe } from "@angular/common";
|
||||||
|
import { AuthService } from "./core/auth/services/auth.service";
|
||||||
|
import { AuthGuard } from "./core/auth/guards/auth.guard";
|
||||||
|
import { UserService } from "./core/user/services/user.service";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -50,7 +53,10 @@ export function createTranslateLoader(http: HttpClient) {
|
|||||||
providers: [
|
providers: [
|
||||||
provideHttpClient(withInterceptorsFromDi()),
|
provideHttpClient(withInterceptorsFromDi()),
|
||||||
TranslatePipe,
|
TranslatePipe,
|
||||||
DatePipe
|
DatePipe,
|
||||||
|
AuthGuard,
|
||||||
|
AuthService,
|
||||||
|
UserService,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import { SharedModule } from "src/app/shared/shared.module";
|
|||||||
import { CoreModule } from "../core.module";
|
import { CoreModule } from "../core.module";
|
||||||
import { AuthComponent } from "./components/auth/auth.component";
|
import { AuthComponent } from "./components/auth/auth.component";
|
||||||
import { AngularSvgIconModule } from "angular-svg-icon";
|
import { AngularSvgIconModule } from "angular-svg-icon";
|
||||||
|
import { AuthService } from "./services/auth.service";
|
||||||
|
import { AuthGuard } from "./guards/auth.guard";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -53,5 +55,9 @@ const routes: Routes = [
|
|||||||
SharedModule,
|
SharedModule,
|
||||||
CoreModule
|
CoreModule
|
||||||
],
|
],
|
||||||
|
providers: [
|
||||||
|
AuthGuard,
|
||||||
|
AuthService,
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class AuthModule {}
|
export class AuthModule {}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
||||||
import { initFlowbite } from "flowbite";
|
import { initFlowbite } from "flowbite";
|
||||||
import { filter, map } from "rxjs";
|
import { filter, map } from "rxjs";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-auth",
|
selector: "app-auth",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-confirm-registration",
|
selector: "app-confirm-registration",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-forgot-password",
|
selector: "app-forgot-password",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
@ -19,7 +19,7 @@ export class LoginComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login(): void {
|
login(): void {
|
||||||
this.authService.login({
|
this.authService.loginUser({
|
||||||
identifier: this.loginForm.value.identifier!,
|
identifier: this.loginForm.value.identifier!,
|
||||||
password: this.loginForm.value.password!,
|
password: this.loginForm.value.password!,
|
||||||
}).subscribe(response => {
|
}).subscribe(response => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-registration",
|
selector: "app-registration",
|
||||||
@ -19,7 +19,7 @@ export class RegistrationComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
register(): void {
|
register(): void {
|
||||||
this.authService.register({
|
this.authService.registerUser({
|
||||||
mail: this.registrationForm.value.mail!,
|
mail: this.registrationForm.value.mail!,
|
||||||
username: this.registrationForm.value.username!,
|
username: this.registrationForm.value.username!,
|
||||||
}).subscribe(response => {
|
}).subscribe(response => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { FormControl, FormGroup, Validators } from "@angular/forms";
|
|||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { initFlowbite } from "flowbite";
|
import { initFlowbite } from "flowbite";
|
||||||
import { filter } from "rxjs";
|
import { filter } from "rxjs";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-reset-password",
|
selector: "app-reset-password",
|
||||||
|
|||||||
@ -2,5 +2,5 @@ export interface LogoutUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LogoutUserResponse {
|
export interface LogoutUserResponse {
|
||||||
response?: string|undefined;
|
response: string;
|
||||||
}
|
}
|
||||||
@ -4,5 +4,5 @@ export interface RegisterUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RegisterUserResponse {
|
export interface RegisterUserResponse {
|
||||||
response?: string|undefined;
|
response: string;
|
||||||
}
|
}
|
||||||
86
src/app/core/auth/services/auth.service.ts
Normal file
86
src/app/core/auth/services/auth.service.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { BehaviorSubject, catchError, Observable } from "rxjs";
|
||||||
|
import { RequestService } from "src/app/core/services/request.service";
|
||||||
|
import { LoginUserRequest, LoginUserResponse } from '../models/login-user.model';
|
||||||
|
import { LogoutUserRequest, LogoutUserResponse } from '../models/logout-user.model';
|
||||||
|
import { ConfirmRegistrationRequest, ConfirmRegistrationResponse } from '../models/confirm-registration.model';
|
||||||
|
import { RegisterUserRequest, RegisterUserResponse } from '../models/register-user.model';
|
||||||
|
import { ForgotPasswordRequest, ForgotPasswordResponse } from '../models/forgot-password.model';
|
||||||
|
import { ResetPasswordRequest, ResetPasswordResponse } from '../models/reset-password.model';
|
||||||
|
import { StateResponse } from "../../user/models/state.model";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AuthService {
|
||||||
|
currentState$ = new BehaviorSubject<StateResponse | undefined>(
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor(private requestService: RequestService) {}
|
||||||
|
|
||||||
|
readUserState()
|
||||||
|
{
|
||||||
|
return this.requestService.request<StateResponse>(
|
||||||
|
'get',
|
||||||
|
this.requestService.obtainUrl("user/state"),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
.pipe(
|
||||||
|
catchError(
|
||||||
|
error => {
|
||||||
|
this.currentState$.next(undefined);
|
||||||
|
throw 'User State not readable';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
loginUser(body: LoginUserRequest): Observable<LoginUserResponse> {
|
||||||
|
return this.requestService.call<LoginUserResponse>(
|
||||||
|
'post',
|
||||||
|
'auth/login-user',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
logoutUser(body: LogoutUserRequest): Observable<LogoutUserResponse> {
|
||||||
|
return this.requestService.call<LogoutUserResponse>(
|
||||||
|
'get',
|
||||||
|
'auth/logout-user',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmRegistration(body: ConfirmRegistrationRequest): Observable<ConfirmRegistrationResponse> {
|
||||||
|
return this.requestService.call<ConfirmRegistrationResponse>(
|
||||||
|
'post',
|
||||||
|
'auth/confirm-registration',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerUser(body: RegisterUserRequest): Observable<RegisterUserResponse> {
|
||||||
|
return this.requestService.call<RegisterUserResponse>(
|
||||||
|
'post',
|
||||||
|
'auth/register-user',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
forgotPassword(body: ForgotPasswordRequest): Observable<ForgotPasswordResponse> {
|
||||||
|
return this.requestService.call<ForgotPasswordResponse>(
|
||||||
|
'post',
|
||||||
|
'auth/forgot-password',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetPassword(body: ResetPasswordRequest): Observable<ResetPasswordResponse> {
|
||||||
|
return this.requestService.call<ResetPasswordResponse>(
|
||||||
|
'post',
|
||||||
|
'auth/reset-password',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,5 @@
|
|||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from "@angular/core";
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { AuthGuard } from "./guards/auth.guard";
|
|
||||||
import { AuthService } from "./services/auth.service";
|
|
||||||
import { RequestService } from "./services/request.service";
|
import { RequestService } from "./services/request.service";
|
||||||
import { AppService } from "./services/app.service";
|
import { AppService } from "./services/app.service";
|
||||||
import { SharedModule } from "../shared/shared.module";
|
import { SharedModule } from "../shared/shared.module";
|
||||||
@ -34,8 +32,6 @@ import { ThemePickerComponent } from "./components/theme-picker/theme-picker.com
|
|||||||
TranslateModule,
|
TranslateModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AuthGuard,
|
|
||||||
AuthService,
|
|
||||||
RequestService,
|
RequestService,
|
||||||
AppService,
|
AppService,
|
||||||
NotificationService,
|
NotificationService,
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { initFlowbite } from "flowbite";
|
import { initFlowbite } from "flowbite";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { StateResponse } from "src/app/core/models/user-state-request.model";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { StateResponse } from "src/app/core/user/models/state.model";
|
||||||
|
import { UserService } from "src/app/core/user/services/user.service";
|
||||||
|
|
||||||
interface NavigationLink {
|
interface NavigationLink {
|
||||||
imageSrc?: string;
|
imageSrc?: string;
|
||||||
@ -57,12 +58,13 @@ export class NavigationComponent implements OnInit {
|
|||||||
state: StateResponse | undefined;
|
state: StateResponse | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private userService: UserService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
this.state = undefined;
|
this.state = undefined;
|
||||||
|
|
||||||
this.authService.readUserState().subscribe(response => {
|
this.userService.state({}).subscribe(response => {
|
||||||
this.authService.currentState$.next(response);
|
this.authService.currentState$.next(response);
|
||||||
this.state = response;
|
this.state = response;
|
||||||
});
|
});
|
||||||
@ -74,7 +76,7 @@ export class NavigationComponent implements OnInit {
|
|||||||
|
|
||||||
logout(): void {
|
logout(): void {
|
||||||
this.authService
|
this.authService
|
||||||
.logout()
|
.logoutUser({})
|
||||||
.subscribe( response => {
|
.subscribe( response => {
|
||||||
this.state = undefined;
|
this.state = undefined;
|
||||||
this.router.navigateByUrl('/')
|
this.router.navigateByUrl('/')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { initFlowbite } from "flowbite";
|
import { initFlowbite } from "flowbite";
|
||||||
import { StateResponse } from "src/app/core/models/user-state-request.model";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { StateResponse } from "src/app/core/user/models/state.model";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-settings",
|
selector: "app-settings",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { AuthService } from "src/app/core/services/auth.service";
|
import { AuthService } from "src/app/core/auth/services/auth.service";
|
||||||
|
import { UserService } from "src/app/core/user/services/user.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-tab-security",
|
selector: "app-tab-security",
|
||||||
@ -20,20 +21,20 @@ export class TabSecurityComponent {
|
|||||||
newUsername: new FormControl("", [Validators.required]),
|
newUsername: new FormControl("", [Validators.required]),
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(private authService: AuthService) {}
|
constructor(private userService: UserService) {}
|
||||||
|
|
||||||
changePassword(): void {
|
changePassword(): void {
|
||||||
if (this.changePasswordForm.value.newPassword !== this.changePasswordForm.value.newPasswordConfirmation)
|
if (this.changePasswordForm.value.newPassword !== this.changePasswordForm.value.newPasswordConfirmation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.changePassword({
|
this.userService.changePassword({
|
||||||
password: this.changePasswordForm.value.password!,
|
password: this.changePasswordForm.value.password!,
|
||||||
newPassword: this.changePasswordForm.value.newPassword!,
|
newPassword: this.changePasswordForm.value.newPassword!,
|
||||||
}).subscribe(response => {});
|
}).subscribe(response => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
changeUsername(): void {
|
changeUsername(): void {
|
||||||
this.authService.changeUsername({
|
this.userService.changeUsername({
|
||||||
password: this.changeUsernameForm.value.password!,
|
password: this.changeUsernameForm.value.password!,
|
||||||
newUsername: this.changeUsernameForm.value.newUsername!,
|
newUsername: this.changeUsernameForm.value.newUsername!,
|
||||||
}).subscribe(response => {});
|
}).subscribe(response => {});
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import { TranslateModule } from "@ngx-translate/core";
|
|||||||
import { SharedModule } from "src/app/shared/shared.module";
|
import { SharedModule } from "src/app/shared/shared.module";
|
||||||
import { AngularSvgIconModule } from "angular-svg-icon";
|
import { AngularSvgIconModule } from "angular-svg-icon";
|
||||||
import { HomeComponent } from "./components/home/home.component";
|
import { HomeComponent } from "./components/home/home.component";
|
||||||
import { AuthGuard } from "../guards/auth.guard";
|
|
||||||
import { SettingsComponent } from "./components/settings/settings.component";
|
import { SettingsComponent } from "./components/settings/settings.component";
|
||||||
import { TabProfileComponent } from "./components/settings/tabs/tab-profile/tab-profile.component";
|
import { TabProfileComponent } from "./components/settings/tabs/tab-profile/tab-profile.component";
|
||||||
import { TabSecurityComponent } from "./components/settings/tabs/tab-security/tab-security.component";
|
import { TabSecurityComponent } from "./components/settings/tabs/tab-security/tab-security.component";
|
||||||
import { NavigationComponent } from "./components/navigation/navigation.component";
|
import { NavigationComponent } from "./components/navigation/navigation.component";
|
||||||
import { CoreModule } from "../core.module";
|
import { CoreModule } from "../core.module";
|
||||||
|
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,122 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { RequestService } from "./request.service";
|
|
||||||
import { StateResponse } from "../models/user-state-request.model";
|
|
||||||
import { BehaviorSubject, catchError, Observable } from "rxjs";
|
|
||||||
import { LoginUserRequest, LoginUserResponse } from "../models/login-request.model";
|
|
||||||
import { Router } from "@angular/router";
|
|
||||||
import {
|
|
||||||
RegisterUserRequest,
|
|
||||||
RegisterUserResponse,
|
|
||||||
} from "../models/register-user-request.model";
|
|
||||||
import {
|
|
||||||
ConfirmRegistrationRequest,
|
|
||||||
ConfirmRegistrationResponse,
|
|
||||||
} from "../models/confirm-registration-request.model";
|
|
||||||
import {
|
|
||||||
ResetPasswordRequest,
|
|
||||||
ResetPasswordResponse,
|
|
||||||
} from "../models/reset-password-request.model";
|
|
||||||
import {
|
|
||||||
ForgotPasswordRequest,
|
|
||||||
ForgotPasswordResponse,
|
|
||||||
} from "../models/forgot-password-request.model";
|
|
||||||
import {
|
|
||||||
ChangePasswordRequest,
|
|
||||||
ChangePasswordResponse,
|
|
||||||
} from "../models/change-password-request.model";
|
|
||||||
import {
|
|
||||||
ChangeUsernameRequest,
|
|
||||||
ChangeUsernameResponse,
|
|
||||||
} from "../models/change-username-request.model";
|
|
||||||
import { LogoutUserResponse } from "../models/logout-request.model";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthService {
|
|
||||||
currentState$ = new BehaviorSubject<StateResponse | undefined>(
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(private requestService: RequestService, private router: Router) {}
|
|
||||||
|
|
||||||
readUserState()
|
|
||||||
{
|
|
||||||
return this.requestService.request<StateResponse>(
|
|
||||||
'get',
|
|
||||||
this.requestService.obtainUrl("user/state"),
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
.pipe(
|
|
||||||
catchError(
|
|
||||||
error => {
|
|
||||||
this.currentState$.next(undefined);
|
|
||||||
throw 'User State not readable';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
logout(): Observable<LogoutUserResponse> {
|
|
||||||
this.currentState$.next(undefined);
|
|
||||||
return this.requestService.call<LogoutUserResponse>(
|
|
||||||
"get",
|
|
||||||
"auth/logout-user",
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
login(body: LoginUserRequest): Observable<LoginUserResponse> {
|
|
||||||
return this.requestService.call<LoginUserResponse>(
|
|
||||||
'post',
|
|
||||||
"auth/login-user",
|
|
||||||
body
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
register(body: RegisterUserRequest): Observable<RegisterUserResponse> {
|
|
||||||
return this.requestService.call<RegisterUserResponse>(
|
|
||||||
"post",
|
|
||||||
"auth/register-user",
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmRegistration(body: ConfirmRegistrationRequest): Observable<ConfirmRegistrationResponse> {
|
|
||||||
return this.requestService.call<ConfirmRegistrationResponse>(
|
|
||||||
'post',
|
|
||||||
'auth/confirm-registration',
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
resetPassword(body: ResetPasswordRequest): Observable<ResetPasswordResponse> {
|
|
||||||
return this.requestService.call<ResetPasswordResponse>(
|
|
||||||
"post",
|
|
||||||
"auth/reset-password",
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
forgotPassword(body: ForgotPasswordRequest): Observable<ForgotPasswordResponse> {
|
|
||||||
return this.requestService.call<ForgotPasswordResponse>(
|
|
||||||
'post',
|
|
||||||
"auth/forgot-password",
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
changePassword(body: ChangePasswordRequest): Observable<ChangePasswordResponse> {
|
|
||||||
return this.requestService.call<ChangePasswordResponse>(
|
|
||||||
'post',
|
|
||||||
"user/change-password",
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
changeUsername(body: ChangeUsernameRequest): Observable<ChangeUsernameResponse> {
|
|
||||||
return this.requestService.call<ChangeUsernameResponse>(
|
|
||||||
'post',
|
|
||||||
"user/change-username",
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
14
src/app/core/user/models/create.model.ts
Normal file
14
src/app/core/user/models/create.model.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export interface CreateRequest {
|
||||||
|
username: string;
|
||||||
|
mail: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateResponse {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
role: "admin"|"user";
|
||||||
|
permissions: string[];
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
18
src/app/core/user/models/read-list.model.ts
Normal file
18
src/app/core/user/models/read-list.model.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export interface ReadListRequest {
|
||||||
|
page: number;
|
||||||
|
perPage: number;
|
||||||
|
query: string|null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReadListResponse {
|
||||||
|
total: number;
|
||||||
|
items: ReadListResponseItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReadListResponseItem {
|
||||||
|
id: string;
|
||||||
|
role: "admin"|"user";
|
||||||
|
username: string;
|
||||||
|
mail: string;
|
||||||
|
lastLoginAt: string|null;
|
||||||
|
}
|
||||||
@ -4,10 +4,9 @@ export interface StateRequest {
|
|||||||
export interface StateResponse {
|
export interface StateResponse {
|
||||||
id: string;
|
id: string;
|
||||||
username: string;
|
username: string;
|
||||||
roleIdentifier: any|null;
|
roleIdentifier: "admin"|"user";
|
||||||
permissions: string[];
|
permissions: string[];
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
role?: "admin"|"user"|undefined;
|
|
||||||
}
|
}
|
||||||
54
src/app/core/user/services/user.service.ts
Normal file
54
src/app/core/user/services/user.service.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { Observable } from "rxjs";
|
||||||
|
import { RequestService } from "src/app/core/services/request.service";
|
||||||
|
import { CreateRequest, CreateResponse } from '../models/create.model';
|
||||||
|
import { ChangePasswordRequest, ChangePasswordResponse } from '../models/change-password.model';
|
||||||
|
import { ChangeUsernameRequest, ChangeUsernameResponse } from '../models/change-username.model';
|
||||||
|
import { ReadListRequest, ReadListResponse } from '../models/read-list.model';
|
||||||
|
import { StateRequest, StateResponse } from '../models/state.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserService {
|
||||||
|
constructor(private requestService: RequestService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
create(body: CreateRequest): Observable<CreateResponse> {
|
||||||
|
return this.requestService.call<CreateResponse>(
|
||||||
|
'post',
|
||||||
|
'user/create',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
changePassword(body: ChangePasswordRequest): Observable<ChangePasswordResponse> {
|
||||||
|
return this.requestService.call<ChangePasswordResponse>(
|
||||||
|
'post',
|
||||||
|
'user/change-password',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeUsername(body: ChangeUsernameRequest): Observable<ChangeUsernameResponse> {
|
||||||
|
return this.requestService.call<ChangeUsernameResponse>(
|
||||||
|
'post',
|
||||||
|
'user/change-username',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
readList(body: ReadListRequest): Observable<ReadListResponse> {
|
||||||
|
return this.requestService.call<ReadListResponse>(
|
||||||
|
'post',
|
||||||
|
'user/read-list',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
state(body: StateRequest): Observable<StateResponse> {
|
||||||
|
return this.requestService.call<StateResponse>(
|
||||||
|
'get',
|
||||||
|
'user/state',
|
||||||
|
body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/app/core/user/user.module.ts
Normal file
21
src/app/core/user/user.module.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { CoreModule } from "../core.module";
|
||||||
|
import { UserService } from "./services/user.service";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
CoreModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
UserService,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class UserModule {}
|
||||||
Loading…
Reference in New Issue
Block a user