Added logic to confirm privacy before registration #251
This commit is contained in:
parent
4420c0e11c
commit
cc0a0a5c69
@ -483,18 +483,19 @@ class AuthService(AuthServiceABC):
|
||||
if user_dto is None:
|
||||
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
|
||||
|
||||
members = self._users.get_users_by_discord_id(dc_id)
|
||||
if members.count() == 0:
|
||||
raise ServiceException(ServiceErrorCode.InvalidUser, f"Member not found")
|
||||
|
||||
added_user = False
|
||||
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
|
||||
if db_user is None:
|
||||
self.add_auth_user(user_dto)
|
||||
added_user = True
|
||||
# raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found')
|
||||
|
||||
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
||||
if db_user.users.count() == 0:
|
||||
self._users.get_users_by_discord_id(dc_id).for_each(
|
||||
lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x))
|
||||
)
|
||||
members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)))
|
||||
|
||||
if db_user.confirmation_id is not None and not added_user:
|
||||
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
||||
|
9562
kdb-web/package-lock.json
generated
9562
kdb-web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kdb-web",
|
||||
"version": "1.0.0.rc2",
|
||||
"version": "1.0.dev251",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"update-version": "ts-node-esm update-version.ts",
|
||||
|
@ -53,9 +53,9 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
this.socket.startSocket();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.unsubscribe();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
loadLang(): void {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { catchError, debounceTime, takeUntil } from "rxjs/operators";
|
||||
import { AuthRoles } from "src/app/models/auth/auth-roles.enum";
|
||||
import { AuthUserDTO } from "src/app/models/auth/auth-user.dto";
|
||||
@ -22,7 +22,7 @@ import { TranslateService } from "@ngx-translate/core";
|
||||
templateUrl: "./auth-user.component.html",
|
||||
styleUrls: ["./auth-user.component.scss"]
|
||||
})
|
||||
export class AuthUserComponent implements OnInit {
|
||||
export class AuthUserComponent implements OnInit, OnDestroy {
|
||||
|
||||
users!: AuthUserDTO[];
|
||||
statuses!: any[];
|
||||
@ -62,7 +62,7 @@ export class AuthUserComponent implements OnInit {
|
||||
searchCriterions!: AuthUserSelectCriterion;
|
||||
totalRecords!: number;
|
||||
|
||||
private unsubscriber = new Subject();
|
||||
private unsubscriber = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
@ -91,6 +91,11 @@ export class AuthUserComponent implements OnInit {
|
||||
this.loadNextPage();
|
||||
}
|
||||
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
setFilterForm() {
|
||||
this.filterForm = this.fb.group({
|
||||
firstName: [""],
|
||||
|
@ -1,15 +1,14 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { SettingsDTO } from 'src/app/models/config/settings.dto';
|
||||
import { ErrorDTO } from 'src/app/models/error/error-dto';
|
||||
import { ServiceErrorCode } from 'src/app/models/error/service-error-code.enum';
|
||||
import { AuthService } from 'src/app/services/auth/auth.service';
|
||||
import { GuiService } from 'src/app/services/gui/gui.service';
|
||||
import { SettingsService } from 'src/app/services/settings/settings.service';
|
||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { catchError } from "rxjs/operators";
|
||||
import { SettingsDTO } from "src/app/models/config/settings.dto";
|
||||
import { ErrorDTO } from "src/app/models/error/error-dto";
|
||||
import { ServiceErrorCode } from "src/app/models/error/service-error-code.enum";
|
||||
import { GuiService } from "src/app/services/gui/gui.service";
|
||||
import { SettingsService } from "src/app/services/settings/settings.service";
|
||||
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||
import { ToastService } from "src/app/services/toast/toast.service";
|
||||
import { throwError } from "rxjs";
|
||||
|
||||
@Component({
|
||||
|
@ -67,11 +67,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-field">
|
||||
<p-checkbox id="confirmPrivacyCheckbox" [binary]="true" formControlName="confirmPrivacy"></p-checkbox>
|
||||
|
||||
<label for="confirmPrivacyCheckbox" [innerHTML]="confirmPrivacyString"></label>
|
||||
</div>
|
||||
|
||||
<div class="login-form-submit">
|
||||
<button pButton label="{{'auth.register.register' | translate}}" class="btn login-form-submit-btn" (click)="register()"
|
||||
[disabled]="loginForm.invalid"></button>
|
||||
</div>
|
||||
|
||||
<div class="login-form-sub-button-wrapper">
|
||||
<div class="login-form-sub-btn-wrapper">
|
||||
<button pButton label="{{'auth.register.login' | translate}}" class="btn login-form-sub-btn" (click)="login()"></button>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { catchError, finalize } from "rxjs/operators";
|
||||
import { catchError, takeUntil } from "rxjs/operators";
|
||||
import { AuthErrorMessages } from "src/app/models/auth/auth-error-messages.enum";
|
||||
import { AuthUserDTO } from "src/app/models/auth/auth-user.dto";
|
||||
import { AuthUserAtrErrors } from "src/app/models/auth/auth-user-atr-errors";
|
||||
@ -9,15 +9,16 @@ import { ErrorDTO } from "src/app/models/error/error-dto";
|
||||
import { ServiceErrorCode } from "src/app/models/error/service-error-code.enum";
|
||||
import { AuthService } from "src/app/services/auth/auth.service";
|
||||
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||
import { throwError } from "rxjs";
|
||||
import { OAuthDTO } from "../../../../models/auth/oauth.dto";
|
||||
import { Subject, throwError } from "rxjs";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { SettingsService } from "../../../../services/settings/settings.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-registration",
|
||||
templateUrl: "./registration.component.html",
|
||||
styleUrls: ["./registration.component.scss"]
|
||||
})
|
||||
export class RegistrationComponent implements OnInit {
|
||||
export class RegistrationComponent implements OnInit, OnDestroy {
|
||||
|
||||
loginForm!: FormGroup<{
|
||||
firstName: FormControl<string | null>,
|
||||
@ -25,7 +26,8 @@ export class RegistrationComponent implements OnInit {
|
||||
email: FormControl<string | null>,
|
||||
emailRepeat: FormControl<string | null>,
|
||||
password: FormControl<string | null>,
|
||||
passwordRepeat: FormControl<string | null>
|
||||
passwordRepeat: FormControl<string | null>,
|
||||
confirmPrivacy: FormControl<boolean | null>
|
||||
}>;
|
||||
submitted = false;
|
||||
authUserAtrErrors!: AuthUserAtrErrors;
|
||||
@ -34,12 +36,17 @@ export class RegistrationComponent implements OnInit {
|
||||
password: false
|
||||
};
|
||||
|
||||
public confirmPrivacyString: string = "";
|
||||
private unsubscriber = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private formBuilder: FormBuilder,
|
||||
private router: Router,
|
||||
private spinnerService: SpinnerService,
|
||||
private route: ActivatedRoute
|
||||
private route: ActivatedRoute,
|
||||
private translate: TranslateService,
|
||||
private settings: SettingsService
|
||||
) {
|
||||
this.spinnerService.showSpinner();
|
||||
this.authService.isUserLoggedInAsync().then(res => {
|
||||
@ -51,12 +58,22 @@ export class RegistrationComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.translate.onLangChange.pipe(takeUntil(this.unsubscriber)).subscribe(lang => {
|
||||
|
||||
this.confirmPrivacyString = this.translate.instant("auth.register.confirm_privacy", { url: this.settings.getPrivacyURL() });
|
||||
});
|
||||
|
||||
this.confirmEMail();
|
||||
this.initData();
|
||||
this.spinnerService.showSpinner();
|
||||
this.initData();
|
||||
}
|
||||
|
||||
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
initData() {
|
||||
this.initLoginForm();
|
||||
this.resetStateFlags();
|
||||
@ -82,7 +99,8 @@ export class RegistrationComponent implements OnInit {
|
||||
email: ["", [Validators.required, Validators.email]],
|
||||
emailRepeat: ["", [Validators.required, Validators.email]],
|
||||
password: ["", [Validators.required, Validators.minLength(8)]],
|
||||
passwordRepeat: ["", [Validators.required, Validators.minLength(8)]]
|
||||
passwordRepeat: ["", [Validators.required, Validators.minLength(8)]],
|
||||
confirmPrivacy: [false, [Validators.required, Validators.requiredTrue]]
|
||||
});
|
||||
}
|
||||
|
||||
@ -143,7 +161,7 @@ export class RegistrationComponent implements OnInit {
|
||||
.pipe(catchError(error => {
|
||||
this.router.navigate(["/auth/login"]);
|
||||
this.spinnerService.hideSpinner();
|
||||
return throwError(() => error);
|
||||
return throwError(() => error);
|
||||
}))
|
||||
.subscribe(resp => {
|
||||
this.spinnerService.hideSpinner();
|
||||
@ -151,4 +169,8 @@ export class RegistrationComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
log($event: Event): void {
|
||||
console.log($event);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
this.loadNextPage();
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { DataService } from "../../../../../../services/data/data.service";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model";
|
||||
@ -28,7 +28,7 @@ import { Subject, throwError } from "rxjs";
|
||||
templateUrl: "./auto-roles-rules.component.html",
|
||||
styleUrls: ["./auto-roles-rules.component.scss"]
|
||||
})
|
||||
export class AutoRolesRulesComponent implements OnInit {
|
||||
export class AutoRolesRulesComponent implements OnInit, OnDestroy {
|
||||
|
||||
rules: AutoRoleRule[] = [];
|
||||
guild: Guild = { channels: [], emojis: [], roles: [] };
|
||||
@ -85,7 +85,6 @@ export class AutoRolesRulesComponent implements OnInit {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
|
||||
this.setFilterForm();
|
||||
this.data.getServerFromRoute(this.route).then(server => {
|
||||
this.server = server;
|
||||
@ -119,6 +118,11 @@ export class AutoRolesRulesComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
public loadNextPage(): void {
|
||||
this.loading = true;
|
||||
this.data.query<AutoRoleRuleQuery>(Queries.autoRoleRulesQuery, {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { User } from "../../../../../../models/data/user.model";
|
||||
import { LazyLoadEvent, MenuItem } from "primeng/api";
|
||||
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
|
||||
@ -28,7 +28,7 @@ import { Server } from "../../../../../../models/data/server.model";
|
||||
templateUrl: "./auto-roles.component.html",
|
||||
styleUrls: ["./auto-roles.component.scss"]
|
||||
})
|
||||
export class AutoRolesComponent implements OnInit {
|
||||
export class AutoRolesComponent implements OnInit, OnDestroy {
|
||||
auto_roles: AutoRole[] = [];
|
||||
guild: Guild = { channels: [], emojis: [], roles: [] };
|
||||
channels: MenuItem[] = [];
|
||||
@ -100,6 +100,12 @@ export class AutoRolesComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
|
||||
public loadNextPage(): void {
|
||||
this.loading = true;
|
||||
this.data.query<AutoRoleQuery>(Queries.autoRolesQuery, {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
|
||||
import { AuthService } from "../../../../services/auth/auth.service";
|
||||
import { SpinnerService } from "../../../../services/spinner/spinner.service";
|
||||
@ -26,7 +26,7 @@ import { Server } from "../../../../models/data/server.model";
|
||||
templateUrl: "./members.component.html",
|
||||
styleUrls: ["./members.component.scss"]
|
||||
})
|
||||
export class MembersComponent implements OnInit {
|
||||
export class MembersComponent implements OnInit, OnDestroy {
|
||||
members!: User[];
|
||||
levels!: MenuItem[];
|
||||
leftServerOptions = [
|
||||
@ -114,6 +114,10 @@ export class MembersComponent implements OnInit {
|
||||
this.loadNextPage();
|
||||
});
|
||||
}
|
||||
public ngOnDestroy(): void {
|
||||
this.unsubscriber.next();
|
||||
this.unsubscriber.complete();
|
||||
}
|
||||
|
||||
loadNextPage() {
|
||||
this.spinner.showSpinner();
|
||||
|
@ -5,7 +5,7 @@
|
||||
"WebVersion": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc2"
|
||||
"Micro": "dev251"
|
||||
},
|
||||
"Themes": [
|
||||
{
|
||||
|
@ -113,7 +113,8 @@
|
||||
"register_with_discord": "Mit Discord Registrieren",
|
||||
"repeat_email": "E-Mail wiederholen",
|
||||
"repeat_password": "Passwort wiederholen",
|
||||
"user_already_exists": "Benutzer existiert bereits"
|
||||
"user_already_exists": "Benutzer existiert bereits",
|
||||
"confirm_privacy": "Ich erkläre mich mit der <a href=\"{{url}}\">Datenschutzerklärung</a> einverstanden."
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
|
@ -113,7 +113,8 @@
|
||||
"register_with_discord": "Register with discord",
|
||||
"repeat_email": "Repeat E-mail",
|
||||
"repeat_password": "Repeat password",
|
||||
"user_already_exists": "User already exists"
|
||||
"user_already_exists": "User already exists",
|
||||
"confirm_privacy": "I agree to the <a href=\"{{url}}\">Privacy Policy</a>."
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
|
Loading…
Reference in New Issue
Block a user