Skip to main content

How to remove the register account service

Tip submitted by @apuntandoanulo & updated by @juandbc

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 Angular

  • 2.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.8 Remove the messages files: src\main\webapp\i18n\ ... \register.json

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

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

2.2 Vue

  • 2.2.1 Remove the entire folder src/main/webapp/app/account/register that contains: register.component.spec.ts, register.component.ts, register.service.ts, register.vue

  • 2.2.2 Go into src/main/webapp/app/router/account.ts and remove the following lines:

    • const Register = () => import('@/account/register/register.vue');
    • And the block:
      {
    path: '/register',
    name: 'Register',
    component: Register,
    },
  • 2.2.3 Go into src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue and remove the following block:

<b-dropdown-item data-cy="register" to="/register" id="register" v-if="!authenticated" active-class="active">
<font-awesome-icon icon="user-plus" />
<span v-text="t$('global.menu.account.register')"></span>
</b-dropdown-item>
  • 2.2.4 Go into src/main/webapp/app/account/login-form/login-form.vue and remove the following block:
<div>
<b-alert show variant="warning">
<span v-text="t$('global.messages.info.register.noaccount')"></span>
<b-link :to="'/register'" class="alert-link" v-text="t$('global.messages.info.register.link')"></b-link>
</b-alert>
</div>
  • 2.2.5 Remove the messages files: src/main/webapp/i18n/.../register.json

  • 2.2.6 Remove the test file src/test/javascript/cypress/e2e/account/register-page.cy.ts