Skip to main content

How to remove the register account service

Tip submitted by @apuntandoanulo

Goal: If you want to eliminate the possibility that users can create accounts and let only a previously registered user do it, remove the following fragments and lines of code that are indicated below:

1. On the back-end side

  • 1.1 src\main\java\ ... \service\UserService.java
    • Remove the entire method public User registerUser(...)
  • 1.2 src\main\java\ ... \rest\AccountResource.java
    • Remove the entire method @PostMapping("/register") public void registerAccount(...)

2. On the front-end side

  • 2.1 src\main\webapp\app\account

    • Remove the entire folder register that contains: register.component.html, register.component.ts, register.route.ts, register.service.ts
  • 2.2 Go into src\main\webapp\app\account\account.module.ts and remove the following lines:

    • import { RegisterComponent } from './register/register.component';
    • declarations array -> RegisterComponent
  • 2.3 Go into src\main\webapp\app\account\account.route.ts and remove the following lines:

    • import { registerRoute } from './register/register.route';
    • ACCOUNT_ROUTES array -> registerRoute
  • 2.4 Go into src\main\webapp\app\home\home.component.html and remove the following block:

<div class="alert alert-warning" *ngSwitchCase="false">
<span jhiTranslate="global.messages.info.register.noaccount">You don't have an account yet?</span>&nbsp;
<a class="alert-link" routerLink="account/register" jhiTranslate="global.messages.info.register.link">Register a new account</a>
</div>
  • 2.5 Go into src\main\webapp\app\layouts\navbar\navbar.component.html and remove the following block:
<li *ngSwitchCase="false">
<a class="dropdown-item" routerLink="account/register" routerLinkActive="active" (click)="collapseNavbar()">
<fa-icon icon="user-plus" [fixedWidth]="true"></fa-icon>
<span jhiTranslate="global.menu.account.register">Register</span>
</a>
</li>
  • 2.6 Go into src\main\webapp\app\shared\login\login.component.html and remove the following block:
<div class="alert alert-warning">
<span jhiTranslate="global.messages.info.register.noaccount">You don't have an account yet?</span>
<a class="alert-link" (click)="register()" jhiTranslate="global.messages.info.register.link">Register a new account</a>
</div>
  • 2.7 Go into src\main\webapp\app\shared\login\login.component.ts and remove the following block:
register(): void {
this.activeModal.dismiss('to state register');
this.router.navigate(['/account/register']);
}
  • 2.8 Remove the messages files: src\main\webapp\i18n\ ... \register.json

  • 2.9 src\test\javascript\spec\app\account

    • Remove the entire folder register that contains: register.component.spec.ts