Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/arpa 53#3 #44

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"lodash-es": "^4.17.20",
"ngx-captcha": "^9.0.1",
"ngx-toastr": "^13.2.0",
"node-modules": "^1.0.1",
"primeflex": "^2.0.0",
Expand Down
260 changes: 131 additions & 129 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,129 +1,131 @@
import { LogoutComponent } from './components/onboarding/logout/logout.component';
import { LoadingComponent } from './components/loading/loading.component';
import { UserListComponent } from './components/dashboards/user-list/user-list.component';
import { environment } from './../environments/environment';
import { LOCAL_STORAGE_TOKEN_KEY } from './services/auth.service';
import { PrimeNgModule } from './modules/prime-ng/prime-ng.module';
import { NoRoleComponent } from './components/dashboards/no-role/no-role.component';
import { NotFoundComponent } from './components/not-found/not-found.component';
import { ForbiddenComponent } from './components/forbidden/forbidden.component';
import { FooterComponent } from './components/shell/footer/footer.component';
import { DashboardComponent } from './components/dashboards/dashboard/dashboard.component';
import { OnboardingShellComponent } from './components/onboarding/onboarding-shell/onboarding-shell.component';
import { MainComponent } from './components/shell/main/main.component';
import { LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { CheckboxModule } from 'primeng/checkbox';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppComponent } from './app.component';
import { ArpalogoComponent } from './components/arpalogo/arpalogo.component';
import { LoginComponent } from './components/onboarding/login/login.component';
import { RegisterComponent } from './components/onboarding/register/register.component';
import { AppRoutingModule } from './app-routing.module';
import { PerformerComponent } from './components/dashboards/performer/performer.component';
import { EmailconfirmationComponent } from './components/onboarding/emailconfirmation/emailconfirmation.component';
import { StaffComponent } from './components/dashboards/staff/staff.component';
import { AdministratorComponent } from './components/dashboards/administrator/administrator.component';
import { TopbarComponent } from './components/shell/topbar/topbar.component';
import { JwtModule } from '@auth0/angular-jwt';
import { WithCredentialsInterceptor } from './interceptors/with-credentials.interceptor';
import { API_URL } from './models/api-url';
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import { ToastrModule } from 'ngx-toastr';
import { ErrorInterceptor } from './interceptors/error.interceptor';
import { ForgotPasswordComponent } from './components/onboarding/forgot-password/forgot-password.component';
import { LanguageMenuComponent } from './components/language-menu/language-menu.component';
import { ProfileComponent } from './components/onboarding/profile/profile.component';
import {AcceptLanguageInterceptor} from './interceptors/accept-language.interceptor';

registerLocaleData(localeDe, 'de');

export function HttpLoaderFactory(httpClient: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(httpClient);
}

export function tokenGetter(): string | null {
return localStorage.getItem(LOCAL_STORAGE_TOKEN_KEY);
}

@NgModule({
declarations: [
AppComponent,
ArpalogoComponent,
LoginComponent,
RegisterComponent,
PerformerComponent,
EmailconfirmationComponent,
StaffComponent,
AdministratorComponent,
MainComponent,
TopbarComponent,
OnboardingShellComponent,
DashboardComponent,
FooterComponent,
ForbiddenComponent,
NotFoundComponent,
NoRoleComponent,
UserListComponent,
LoadingComponent,
LogoutComponent,
ForgotPasswordComponent,
LanguageMenuComponent,
ProfileComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
ReactiveFormsModule,
HttpClientModule,
FormsModule,
CheckboxModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
AppRoutingModule,
PrimeNgModule,
JwtModule.forRoot({
config: {
tokenGetter,
allowedDomains: [environment.api.baseUrl],
disallowedRoutes: [],
},
}),
ToastrModule.forRoot({
progressBar: true,
positionClass: 'toast-top-full-width'
}),
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: WithCredentialsInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: AcceptLanguageInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorInterceptor,
multi: true,
},
{ provide: API_URL, useValue: `${environment.api.protocol}://${environment.api.baseUrl}` },
{ provide: LOCALE_ID, useValue: 'de-de' },
],
bootstrap: [AppComponent],
})
export class AppModule {}
import { LogoutComponent } from './components/onboarding/logout/logout.component';
import { LoadingComponent } from './components/loading/loading.component';
import { UserListComponent } from './components/dashboards/user-list/user-list.component';
import { environment } from './../environments/environment';
import { LOCAL_STORAGE_TOKEN_KEY } from './services/auth.service';
import { PrimeNgModule } from './modules/prime-ng/prime-ng.module';
import { NoRoleComponent } from './components/dashboards/no-role/no-role.component';
import { NotFoundComponent } from './components/not-found/not-found.component';
import { ForbiddenComponent } from './components/forbidden/forbidden.component';
import { FooterComponent } from './components/shell/footer/footer.component';
import { DashboardComponent } from './components/dashboards/dashboard/dashboard.component';
import { OnboardingShellComponent } from './components/onboarding/onboarding-shell/onboarding-shell.component';
import { MainComponent } from './components/shell/main/main.component';
import { LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { CheckboxModule } from 'primeng/checkbox';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppComponent } from './app.component';
import { ArpalogoComponent } from './components/arpalogo/arpalogo.component';
import { LoginComponent } from './components/onboarding/login/login.component';
import { RegisterComponent } from './components/onboarding/register/register.component';
import { AppRoutingModule } from './app-routing.module';
import { PerformerComponent } from './components/dashboards/performer/performer.component';
import { EmailconfirmationComponent } from './components/onboarding/emailconfirmation/emailconfirmation.component';
import { StaffComponent } from './components/dashboards/staff/staff.component';
import { AdministratorComponent } from './components/dashboards/administrator/administrator.component';
import { TopbarComponent } from './components/shell/topbar/topbar.component';
import { JwtModule } from '@auth0/angular-jwt';
import { WithCredentialsInterceptor } from './interceptors/with-credentials.interceptor';
import { API_URL } from './models/api-url';
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
import { ToastrModule } from 'ngx-toastr';
import { ErrorInterceptor } from './interceptors/error.interceptor';
import { ForgotPasswordComponent } from './components/onboarding/forgot-password/forgot-password.component';
import { LanguageMenuComponent } from './components/language-menu/language-menu.component';
import { ProfileComponent } from './components/onboarding/profile/profile.component';
import { NgxCaptchaModule } from 'ngx-captcha';
import {AcceptLanguageInterceptor} from './interceptors/accept-language.interceptor';

registerLocaleData(localeDe, 'de');

export function HttpLoaderFactory(httpClient: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(httpClient);
}

export function tokenGetter(): string | null {
return localStorage.getItem(LOCAL_STORAGE_TOKEN_KEY);
}

@NgModule({
declarations: [
AppComponent,
ArpalogoComponent,
LoginComponent,
RegisterComponent,
PerformerComponent,
EmailconfirmationComponent,
StaffComponent,
AdministratorComponent,
MainComponent,
TopbarComponent,
OnboardingShellComponent,
DashboardComponent,
FooterComponent,
ForbiddenComponent,
NotFoundComponent,
NoRoleComponent,
UserListComponent,
LoadingComponent,
LogoutComponent,
ForgotPasswordComponent,
LanguageMenuComponent,
ProfileComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
ReactiveFormsModule,
HttpClientModule,
FormsModule,
CheckboxModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
AppRoutingModule,
PrimeNgModule,
JwtModule.forRoot({
config: {
tokenGetter,
allowedDomains: [environment.api.baseUrl],
disallowedRoutes: [],
},
}),
ToastrModule.forRoot({
progressBar: true,
positionClass: 'toast-top-full-width'
}),
NgxCaptchaModule,
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: WithCredentialsInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: AcceptLanguageInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: ErrorInterceptor,
multi: true,
},
{ provide: API_URL, useValue: `${environment.api.protocol}://${environment.api.baseUrl}` },
{ provide: LOCALE_ID, useValue: 'de-de' },
],
bootstrap: [AppComponent],
})
export class AppModule {}
13 changes: 12 additions & 1 deletion src/app/components/onboarding/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
<label for="float-input">{{ 'PASSWORD' | translate }}</label>
<i id="eyeButton" class="p-ml-2 pi {{hide ? 'pi-eye-slash' : 'pi-eye'}}" (click)="hide = !hide"></i>
</p>
<p-captcha #cpt [siteKey] = "captchaKey" theme = 'dark' [language]="language" (onResponse)="showResponse($event)" initCallback="loadCaptcha"></p-captcha>
<ngx-recaptcha2 #captchaElem
[siteKey]="captchaKey"
(success) = "showResponse($event)"
[useGlobalDomain]="false"
size="normal"
[hl]="'SHORTCUT' | translate"
theme="dark"
type="image"
formControlName="recaptcha">
</ngx-recaptcha2>
<p style="height:10px"></p>
<table>
<tr>
<td>
<button
pButton
label="{{ 'LOGIN' | translate }}"
[disabled]="loginFormGroup.invalid || loginFormGroup.pristine ">
[disabled]="loginFormGroup.invalid || loginFormGroup.pristine || !captchaSuccess">
</button>
</td>
<td width="20px;"></td>
Expand Down
31 changes: 29 additions & 2 deletions src/app/components/onboarding/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { environment } from './../../../../environments/environment';
import { SubSink } from 'subsink';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, Renderer2 } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { AuthService } from '../../../services/auth.service';
import { ToastService } from '../../../services/toast.service';
import { LoadingService} from '../../../services/loading.service';
import { TranslateService } from '@ngx-translate/core';

export const LOCAL_STORAGE_TOKEN_KEY = 'token';

Expand All @@ -19,12 +21,18 @@ export class LoginComponent implements OnInit, OnDestroy {
loginRequest = false;
private subs = new SubSink();
hide = true;
language: string;
captchaSuccess = false;
captchaKey = environment.captcha.key;
script: any;

constructor(formBuilder: FormBuilder,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das Captcha sollte glaub ich ins Registrierungsformular und nicht ins Login :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hatte mit Michael besprochen dass ich es hier rein mach. Geht aber natürlich auch auf der anderen Seite

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brauchen wir das im Login @MichaelSpielmann ? Hätte es jetzt auch eher auf der Registerseite verortet um Spam-Registrierungen zu vermeiden.. beim login is ja wurscht denk ich, oder?

private router: Router,
private authService: AuthService,
private toastService: ToastService,
private loadingService: LoadingService
private loadingService: LoadingService,
private translate: TranslateService,
private renderer: Renderer2,
) {
this.loginFormGroup = formBuilder.group({
usernameOrEmail: [null,
Expand All @@ -40,10 +48,25 @@ export class LoginComponent implements OnInit, OnDestroy {
Validators.minLength(6),
],
],
recaptcha: [null, Validators.required],
});
}

ngOnInit(): void {
this.translate
.stream('SHORTCUT')
.subscribe(v => this.setLanguage(v));
this.script = this.renderer.createElement('script');
this.script = this.renderer.createElement('script');
this.script.defer = true;
this.script.async = true;
this.script.src = 'https://www.google.com/recaptcha/api.js?render=explicit&onload=loadCaptcha';
this.renderer.appendChild(document.body, this.script);
}

setLanguage(param: any): void {
this.language = param;
console.log(this.language);
}

ngOnDestroy(): void {
Expand Down Expand Up @@ -88,6 +111,10 @@ export class LoginComponent implements OnInit, OnDestroy {
})
);
}

showResponse(response: any): void {
this.captchaSuccess = true;
}
}


Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/prime-ng/prime-ng.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { InputNumberModule } from 'primeng/inputnumber';
import { FullCalendarModule } from 'primeng/fullcalendar';
import { ConfirmDialogModule } from 'primeng/confirmdialog';
import { DialogService, DynamicDialogModule } from 'primeng/dynamicdialog';
import {CaptchaModule} from 'primeng/captcha';

const MODULES = [
InputTextModule,
Expand Down Expand Up @@ -55,6 +56,7 @@ const MODULES = [
FullCalendarModule,
ConfirmDialogModule,
DynamicDialogModule,
CaptchaModule
];

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"SHORTCUT": "de",
"EMAILADDRESS": "E-Mailadresse",
"USERNAME": "Benutzername",
"GIVENNAME": "Vorname",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"SHORTCUT": "en",
"EMAILADDRESS": "Email address",
"USERNAME": "Username",
"GIVENNAME": "Given name",
Expand Down
Loading