cleaning
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m57s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 21s

This commit is contained in:
2024-03-07 17:02:19 +01:00
parent 8b35b3dc01
commit 6b58c852a2
4 changed files with 66 additions and 51 deletions

View File

@ -27,25 +27,11 @@ public class TokenService {
return token;
}
//todo potentiellement return bool pour savoir si token bien add
public void saveToken(String token, User user, Date expirationDate){
tokenRepo.save(new Token(user,token));
}
public User getUserFromToken(String token){
return tokenRepo.getByToken(token).getUser();
}
/** Take the list of mock user to save them in the Token DB
* With token being the password of the user (also his role)
* @param users an
*/
public void postMockToken(Iterable<User> users){
for (User user: users){
tokenRepo.save(new Token(user,user.getPassword()));
}
public void saveToken(String token, User user, Date expirationDate){// todo faire qlq chose de l'expDate
tokenRepo.save(new Token(user,token));
}
}

View File

@ -39,27 +39,6 @@ public class UserService {
return passwordEncoder.matches(tryingPassword, user.getPassword());
}
/** Saves an example of :
* an Admin with id 1, email : admin@admin.com and password: admin
* a Student with id 2, email: student@student.com and password: student (no cursus yet)
* a Secretary with id 3, email: secretary@secretary.com and password: secretary
* a Teacher (same)
* and they all have silly names (hihi)
*/
public Iterable<User> postMockUsers(){
User herobrine = new User("brine","hero","admin@admin.com","in your WalLs","ShadowsLand",new Date(0), Role.Admin,passwordEncoder.encode("admin"));
User Joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), Role.Student,passwordEncoder.encode("student"));
User Meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), Role.Teacher,passwordEncoder.encode("secretary"));
User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), Role.Teacher,passwordEncoder.encode("teacher"));
userRepo.save(herobrine);
userRepo.save(Joe);
userRepo.save(Meh);
userRepo.save(joke);
return new ArrayList<User>(Arrays.asList(herobrine,Joe,Meh,joke));
}
public void save(User user){
userRepo.save(user);
}