parent
9f21811652
commit
2c0f0f2c14
|
|
@ -35,7 +35,7 @@ public class AuthenticationController extends AbstractRestController {
|
|||
}
|
||||
|
||||
@PostMapping("/pwdReset")
|
||||
public ResponseEntity resetPassword(@RequestBody AuthenticationRequest request) {
|
||||
public ResponseEntity<AuthenticationRequest> resetPassword(@RequestBody AuthenticationRequest request) {
|
||||
|
||||
if (authenticationService.emailExists(request.getUsername())) {
|
||||
request.setPassword(authenticationService.resetPassword(request.getUsername(), utilsService.generateAccessToken()));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package eu.csc.ODPAppVehOwnServer.client;
|
||||
|
||||
import eu.csc.ODPAppVehOwnServer.client.clients.VehOwnAppClient;
|
||||
import eu.csc.ODPAppVehOwnServer.client.service.IApiService;
|
||||
import eu.csc.ODPAppVehOwnServer.models.JWTTokenResponse;
|
||||
import eu.csc.ODPAppVehOwnServer.models.auth.AuthenticationRequest;
|
||||
import eu.csc.odpconfigserver.client.adapter.ErrorHandlingCallAdapterFactory;
|
||||
|
|
@ -31,15 +32,27 @@ public class ClientFactory {
|
|||
.addConverterFactory(GsonConverterFactory.create());
|
||||
}
|
||||
|
||||
public static <S> S createService(String url, Class<S> serviceClass) {
|
||||
public static <S extends IApiService> S createService(String url, Class<S> serviceClass) {
|
||||
return createAuthenticatedService(url, serviceClass, null);
|
||||
}
|
||||
|
||||
public static <S extends IApiService> S createService(String url, Class<S> serviceClass, String user, String password) {
|
||||
|
||||
return createAuthenticatedService(url, serviceClass, new BasicAuthenticationInterceptor(user, password));
|
||||
}
|
||||
|
||||
|
||||
//region Services
|
||||
|
||||
public static AuthenticationService createAuthenticationService(String url) {
|
||||
return createService(url, AuthenticationService.class);
|
||||
}
|
||||
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
public static VehOwnAppClient createVehOwnAppClient(String url) {
|
||||
return new VehOwnAppClient(url);
|
||||
}
|
||||
|
|
@ -48,12 +61,6 @@ public class ClientFactory {
|
|||
return new VehOwnAppClient(url, token);
|
||||
}
|
||||
|
||||
public static <S> S createService(String url, Class<S> serviceClass, String user, String password) {
|
||||
|
||||
|
||||
return createAuthenticatedService(url, serviceClass, new BasicAuthenticationInterceptor(user, password));
|
||||
}
|
||||
|
||||
|
||||
public static <S> S createService(String url, Class<S> serviceClass, final String token) {
|
||||
|
||||
|
|
@ -91,18 +98,18 @@ public class ClientFactory {
|
|||
AuthenticationRequest request = new AuthenticationRequest();
|
||||
request.setPassword(password);
|
||||
request.setUsername(login);
|
||||
|
||||
return service.login(request).execute();
|
||||
}
|
||||
|
||||
public static retrofit2.Response<JWTTokenResponse> resetPassword(String url, String login, String password) throws IOException {
|
||||
public static AuthenticationRequest resetPassword(String url, String login, String password) throws IOException {
|
||||
AuthenticationService service = createService(url, AuthenticationService.class);
|
||||
|
||||
AuthenticationRequest request = new AuthenticationRequest();
|
||||
request.setPassword(password);
|
||||
request.setUsername(login);
|
||||
//return service.passwordReset(request).execute();
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
return createAuthenticationService(url).resetPassword(request).execute().body();
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,15 @@ import retrofit2.http.Body;
|
|||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AuthenticationService {
|
||||
public interface AuthenticationService extends IApiService {
|
||||
|
||||
@POST("/api/login")
|
||||
Call<JWTTokenResponse> login(@Body AuthenticationRequest body);
|
||||
|
||||
|
||||
@POST("/api/signup")
|
||||
Call<Long> registerCustomer(@Body UserRegistrationDto body);
|
||||
|
||||
@POST("/api/pwdReset")
|
||||
Call<AuthenticationRequest> resetPassword(@Body AuthenticationRequest body);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import retrofit2.http.Path;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface ClientService {
|
||||
public interface ClientService extends IApiService{
|
||||
|
||||
|
||||
@GET("/api/languages")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import retrofit2.http.Path;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomerService {
|
||||
public interface CustomerService extends IApiService{
|
||||
|
||||
//region registration
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import retrofit2.http.GET;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface DataClientService {
|
||||
public interface DataClientService extends IApiService {
|
||||
|
||||
//region Vehicle
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package eu.csc.ODPAppVehOwnServer.client.service;
|
||||
|
||||
public interface IApiService {
|
||||
}
|
||||
Loading…
Reference in New Issue