Code moving and fix login component style.
This commit is contained in:
@@ -29,10 +29,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package org.sportshub.application.security;
|
||||
package org.sportshub.exposition.configuration.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
|
||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||
import org.sportshub.application.security.JwtService;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.sportshub.exposition.configuration;
|
||||
package org.sportshub.exposition.configuration.security;
|
||||
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
import static org.springframework.http.HttpMethod.OPTIONS;
|
||||
import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS;
|
||||
import org.sportshub.application.security.JwtAuthenticationFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.Customizer;
|
||||
@@ -12,8 +11,6 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.sportshub.exposition.user;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.sportshub.application.security.annotation.AllowedToAdmins;
|
||||
import org.sportshub.application.security.annotation.AllowedToAnonymous;
|
||||
import org.sportshub.application.user.UserUseCases;
|
||||
import org.sportshub.domain.user.model.User;
|
||||
import org.sportshub.domain.user.model.UserAuthenticationData;
|
||||
@@ -24,12 +26,14 @@ public class UserController {
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@AllowedToAnonymous
|
||||
public LoginResponse login(@RequestBody LoginRequest request) {
|
||||
UserAuthenticationData userAuthenticationData = userUseCases.authenticate(request.id(), request.password());
|
||||
return new LoginResponse(userAuthenticationData);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@AllowedToAdmins
|
||||
public List<User> findAll() {
|
||||
return userUseCases.findAll();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<form (ngSubmit)="onSubmit()" [formGroup]="loginForm" ngNativeValidate>
|
||||
<form (ngSubmit)="onSubmit()" class="shadowed" [formGroup]="loginForm" ngNativeValidate>
|
||||
<div>
|
||||
<label for="id">Identifier</label>
|
||||
<input id="id" name="id" formControlName="id"/>
|
||||
<input id="id" name="id" formControlName="id" class="input" required/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Password</label>
|
||||
<input id="password" name="password" type="password" formControlName="password"/>
|
||||
<input id="password" name="password" type="password" formControlName="password" class="input" required/>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit">Validate</button>
|
||||
<button type="submit" class="btn">Validate</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,19 @@
|
||||
:host {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: solid 1px #e8e8e8;
|
||||
padding: 1em;
|
||||
border-radius: .5em;
|
||||
gap: 1em;
|
||||
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,9 @@ export class LoginComponent {
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
const loginRequest: LoginRequest = this.loginForm.value;
|
||||
this.loginService.login(loginRequest);
|
||||
if (this.loginForm.valid) {
|
||||
const loginRequest: LoginRequest = this.loginForm.value;
|
||||
this.loginService.login(loginRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<a class="title" routerLink="/">SportsHub</a>
|
||||
<div id="menu">
|
||||
<a routerLink="/login" *ngIf="(isAuthenticated$ | async) === false">
|
||||
<a routerLink="/login" *ngIf="(isAuthenticated$ | async) === false" class="btn">
|
||||
<mat-icon>login</mat-icon>
|
||||
Login
|
||||
</a>
|
||||
<a routerLink="/logout" *ngIf="isAuthenticated$ | async" class="logout">
|
||||
<a routerLink="/logout" *ngIf="isAuthenticated$ | async" class="btn logout">
|
||||
<mat-icon>logout</mat-icon>
|
||||
Logout
|
||||
</a>
|
||||
|
||||
@@ -24,14 +24,6 @@
|
||||
|
||||
a {
|
||||
flex: 0 1;
|
||||
background-color: #008cff;
|
||||
color: white;
|
||||
border-radius: .5em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: .5em 1em;
|
||||
text-decoration: none;
|
||||
gap: .5em;
|
||||
|
||||
&.logout {
|
||||
|
||||
@@ -2,3 +2,25 @@
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
|
||||
.shadowed {
|
||||
box-shadow: 0 3px 1px -2px #0003,0 2px 2px #00000024,0 1px 5px #0000001f;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background-color: #008cff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: .4em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: .5em 1em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.input {
|
||||
padding: .5em;
|
||||
border-radius: .4em;
|
||||
border: 1px solid #d2d2d2
|
||||
}
|
||||
Reference in New Issue
Block a user