argos/dmp-backend/src/main/java/eu/eudat/controllers/Login.java

37 lines
1.3 KiB
Java
Raw Normal View History

2017-12-15 17:57:41 +01:00
package eu.eudat.controllers;
import eu.eudat.managers.DataManagementPlanManager;
import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
import eu.eudat.models.helpers.DataTableData;
import eu.eudat.models.login.Credentials;
import eu.eudat.models.responses.ResponseItem;
import eu.eudat.models.security.Principal;
import eu.eudat.security.CustomAuthenticationProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
/**
* Created by ikalyvas on 12/15/2017.
*/
@RestController
@CrossOrigin
@RequestMapping(value = "/login")
public class Login {
@Autowired
private CustomAuthenticationProvider customAuthenticationProvider;
@RequestMapping(method = RequestMethod.POST, value = { "/googlelogin" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody Credentials credentials) {
try {
return new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK);
} catch (Exception ex) {
ex.printStackTrace();
return new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
}
}