Added refresh token endpoint

This commit is contained in:
Filip Izydorczyk
2020-12-23 11:51:17 +01:00
parent 7f630ccdac
commit 61c5a43192
7 changed files with 45 additions and 11 deletions

View File

@ -1,6 +1,7 @@
package com.plannaplan.entities;
import java.sql.Timestamp;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.persistence.Entity;
@ -28,6 +29,7 @@ public class User {
private String usosId;
private UserRoles role;
private String token;
private String refreshToken;
private Timestamp tokenUsageDate;
public User() {
@ -105,6 +107,13 @@ public class User {
return token;
}
/**
* @return token needed to call refresh token after it expired
*/
public String getRefreshToken() {
return refreshToken;
}
/**
* token seter. Sets token and automaticly set time when was set
*
@ -113,6 +122,7 @@ public class User {
public void setToken(String token) {
this.tokenUsageDate = new Timestamp(System.currentTimeMillis());
this.token = token;
this.refreshToken = UUID.randomUUID().toString();
}
/**