LoginController.java 1.41 KB
package etunicorn;

import net.minidev.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * etunicorn-server
 * Copyright © 2017 Le Club Info Polytech Lille
 * Tous droits réservés
 */
@RestController
public class LoginController implements etunicorn.generated.LoginController {
    @Autowired
    private PermissionRepository permissionRepository;

    @Override
    public ResponseEntity<?> updateLogin(@RequestParam String login, @RequestParam String password) {
        // TODO C'est du debug !
        Role role = new Role();
        role.setNom("superman");
        for (Permission permission : permissionRepository.findAll()) {
            role.addPermission(permission);
        }
        Personne personne = new Personne();
        personne.setLogin("gbontoux");
        personne.setCarte("39cdd9ed0b191d");
        personne.setNaissance(new Date("14-Feb-1997"));
        personne.setRole(role);
        return new ResponseEntity<Object>(personne, HttpStatus.OK);
    }

    @Override
    public ResponseEntity<?> deleteLoginByToken(@PathVariable String token) {
        return null;
    }
}