Merge pull request 'Max/Backend/RegisterEndPoint' (#105) from Max/Backend/RegisterEndPoint into master
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m11s
deploy to production / deploy-frontend (push) Successful in 24s
Build and test backend / Test-backend (push) Successful in 1m20s
deploy to production / deploy-backend (push) Successful in 2m21s
Build and test FrontEnd / Build-frontend (push) Successful in 23s
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m11s
deploy to production / deploy-frontend (push) Successful in 24s
Build and test backend / Test-backend (push) Successful in 1m20s
deploy to production / deploy-backend (push) Successful in 2m21s
Build and test FrontEnd / Build-frontend (push) Successful in 23s
Reviewed-on: #105 Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com> Reviewed-by: LeoMoulin <leomoulin125@gmail.com> Reviewed-by: Wal <karpinskiwal@gmail.com>
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.EndPoints.LoginController;
|
||||
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.Token;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@ -11,10 +14,12 @@ public class AuthenticatorService {
|
||||
|
||||
private final TokenService tokenService;
|
||||
private final UserService userService;
|
||||
private final InscriptionService inscriptionService;
|
||||
|
||||
public AuthenticatorService(TokenService tokenService, UserService userService){
|
||||
public AuthenticatorService(TokenService tokenService, UserService userService, InscriptionService inscriptionService){
|
||||
this.tokenService = tokenService;
|
||||
this.userService = userService;
|
||||
this.inscriptionService = inscriptionService;
|
||||
}
|
||||
|
||||
public User getUserFromToken(String token){
|
||||
@ -30,4 +35,8 @@ public class AuthenticatorService {
|
||||
tokenService.saveToken(new Token(user, token,expirationDate));
|
||||
return token;
|
||||
}
|
||||
|
||||
public void register(InscriptionRequest inscriptionRequest) {
|
||||
inscriptionService.save(inscriptionRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class InscriptionService {
|
||||
|
||||
InscriptionRepository incriptionRepo;
|
||||
public void save(InscriptionRequest inscriptionRequest){
|
||||
incriptionRepo.save(inscriptionRequest);
|
||||
}
|
||||
|
||||
public InscriptionService(InscriptionRepository inscriptionRepo){
|
||||
this.incriptionRepo = inscriptionRepo;
|
||||
}
|
||||
|
||||
public InscriptionRequest getById(long id){
|
||||
InscriptionRequest inscriptionRequest = incriptionRepo.findById(id);
|
||||
|
||||
if (inscriptionRequest == null){
|
||||
return null;
|
||||
}
|
||||
return inscriptionRequest;
|
||||
}
|
||||
|
||||
public Iterable<InscriptionRequest> getAll(){
|
||||
return incriptionRepo.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user