Implement Authentication Filter (2.1.3.3)
This commit is contained in:
+2
-3
@@ -7,7 +7,6 @@ import dst.ass2.service.auth.client.AuthenticationClientProperties;
|
||||
import dst.ass2.service.auth.client.IAuthenticationClient;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
|
||||
public class GrpcAuthenticationClient implements IAuthenticationClient {
|
||||
private final ManagedChannel channel;
|
||||
@@ -23,10 +22,10 @@ public class GrpcAuthenticationClient implements IAuthenticationClient {
|
||||
AuthenticationRequest request = AuthenticationRequest.newBuilder().setEmail(email).setPassword(password).build();
|
||||
AuthenticationResponse response = blockingStub.authenticate(request);
|
||||
|
||||
if(response.getStatus().startsWith("NoSuchUserException"))
|
||||
if(response.getStatus().contains("NoSuchUserException"))
|
||||
throw new NoSuchUserException("User with email " + email + " could not be found");
|
||||
|
||||
if(response.getStatus().startsWith("AuthenticationException"))
|
||||
if(response.getStatus().contains("AuthenticationException"))
|
||||
throw new AuthenticationException("Password for user with email " + email + " was incorrect");
|
||||
|
||||
return response.getToken();
|
||||
|
||||
Reference in New Issue
Block a user