Improved security

This commit is contained in:
Carlos
2020-12-05 13:26:04 +01:00
parent d2696df7bc
commit dd9003190a
9 changed files with 181 additions and 28 deletions

View File

@ -46,11 +46,23 @@ public class LoginManager {
}
/**
* Check if user is logged in
* Check if user is logged in. It checks that both the socket adress and the user token corresponds to a logged in user.
* @param address User to check
* @return true if user is logged in, false otherwise
*/
public boolean isLoggedIn(InetSocketAddress address) {
public boolean isLoggedIn(InetSocketAddress address, String token) {
for(ConnectedUser user : loggedInUsers)
if(user.getSocketAddress().equals(address) && user.getToken().equals(token))
return true;
return false;
}
/**
* Check if an user is logged in from a given socket address
* @param address User to check
* @return true if user is logged in, false otherwise
*/
public boolean isSocketConnected(InetSocketAddress address) {
for(ConnectedUser user : loggedInUsers)
if(user.getSocketAddress().equals(address))
return true;