fixed a token encoding issue
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.TokenRepository;
|
||||
import ovh.herisson.Clyde.Tables.Token;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Date;
|
||||
@ -22,9 +24,12 @@ public class TokenService {
|
||||
public String generateNewToken(){
|
||||
byte[] bytes = new byte[64];
|
||||
new SecureRandom().nextBytes(bytes);
|
||||
String token = new String(bytes, StandardCharsets.US_ASCII);
|
||||
System.out.println(token);
|
||||
return token;
|
||||
// will never end up in the catch because of the way that SecureRandom.nextBytes is implemented
|
||||
try {
|
||||
return new String(bytes,"ISO_8859_1");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public User getUserFromToken(String token){
|
||||
|
||||
Reference in New Issue
Block a user