Add ability to override login signup message
authorChocobozzz <me@florianbigard.com>
Wed, 6 May 2020 12:01:30 +0000 (14:01 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 6 May 2020 12:03:23 +0000 (14:03 +0200)
client/src/app/core/plugins/hooks.service.ts
client/src/app/core/plugins/plugin.service.ts
client/src/app/login/login.component.html
client/src/app/login/login.component.ts
shared/models/plugins/client-hook.model.ts
shared/models/plugins/plugin-client-scope.type.ts

index a6a444c326a4b3392f1cd651890c07894922b224..2fbf406d119e663fb1b95f6db4064f3ca14f8435 100644 (file)
@@ -1,9 +1,8 @@
+import { from, Observable } from 'rxjs'
+import { mergeMap, switchMap } from 'rxjs/operators'
 import { Injectable } from '@angular/core'
 import { PluginService } from '@app/core/plugins/plugin.service'
 import { ClientActionHookName, ClientFilterHookName } from '@shared/models/plugins/client-hook.model'
-import { from, Observable } from 'rxjs'
-import { mergeMap, switchMap } from 'rxjs/operators'
-import { ServerService } from '@app/core/server'
 import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
 
 type RawFunction<U, T> = (params: U) => T
@@ -11,10 +10,7 @@ type ObservableFunction<U, T> = RawFunction<U, Observable<T>>
 
 @Injectable()
 export class HooksService {
-  constructor (
-    private server: ServerService,
-    private pluginService: PluginService
-  ) { }
+  constructor (private pluginService: PluginService) { }
 
   wrapObsFun
     <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
index 3ed23160dfb5d9366108ed263f5fe85a22e25b3c..c6efcac6d3db146f3c4602b871396a4e57da019f 100644 (file)
@@ -47,7 +47,8 @@ export class PluginService implements ClientHook {
     common: new ReplaySubject<boolean>(1),
     search: new ReplaySubject<boolean>(1),
     'video-watch': new ReplaySubject<boolean>(1),
-    signup: new ReplaySubject<boolean>(1)
+    signup: new ReplaySubject<boolean>(1),
+    login: new ReplaySubject<boolean>(1)
   }
 
   translationsObservable: Observable<PluginTranslation>
index a935c86c37f62050a2d4f63c40b9420abf9a546c..599b203ae74977b4b30c080d34a94892101a85eb 100644 (file)
@@ -8,7 +8,7 @@
   </div>
 
   <ng-container *ngIf="!externalAuthError && !isAuthenticatedWithExternalAuth">
-    <div class="alert alert-info" *ngIf="signupAllowed === false" role="alert">
+    <div class="looking-for-account alert alert-info" *ngIf="signupAllowed === false" role="alert">
       <h6 class="alert-heading" i18n>
         If you are looking for an account…
       </h6>
index 5d935cb49d7235734c0fa6126666d631abb59873..fff4b43f6f27f968bdd6cc2129e91dff82b21812 100644 (file)
@@ -10,6 +10,7 @@ import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
 import { ActivatedRoute } from '@angular/router'
 import { ServerConfig, RegisteredExternalAuthConfig } from '@shared/models/server/server-config.model'
 import { environment } from 'src/environments/environment'
+import { HooksService } from '@app/core/plugins/hooks.service'
 
 @Component({
   selector: 'my-login',
@@ -40,6 +41,7 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
     private userService: UserService,
     private redirectService: RedirectService,
     private notifier: Notifier,
+    private hooks: HooksService,
     private i18n: I18n
   ) {
     super()
@@ -78,6 +80,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
     if (this.usernameInput) {
       this.usernameInput.nativeElement.focus()
     }
+
+    this.hooks.runAction('action:login.init', 'login')
   }
 
   getExternalLogins () {
index 62f6070d796f51d35601e26c2aebfb408453b049..b53b8de99ce7c138d8c22c5bb6115d07e49e025a 100644 (file)
@@ -70,6 +70,9 @@ export const clientActionHookObject = {
   // Fired when a user click on 'View x replies' and they're loaded
   'action:video-watch.video-thread-replies.loaded': true,
 
+  // Fired when the login page is being initialized
+  'action:login.init': true,
+
   // Fired when the search page is being initialized
   'action:search.init': true,
 
index 1c6d884f0f722b6b2abe39dc96aaf518cf254797..d112434e89f973a06f7b35ceb663ac1c5e887c4c 100644 (file)
@@ -1 +1 @@
-export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup'
+export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup' | 'login'