Authorisation is no longer being done by the user controller, so there's no point to keep those calls in.
このコミットが含まれているのは:
コミット
75a2e43adc
|
@ -84,73 +84,6 @@ class UserController extends Controller {
|
|||
->get();
|
||||
}
|
||||
|
||||
public function isAuth(Request $request) { // /apt/rpc/user/auth/isauth
|
||||
return $request->cookie('username');
|
||||
}
|
||||
|
||||
public function login(Request $request) { // /api/rpc/user/auth/login
|
||||
$getUser = DB::table('users')
|
||||
->select('id', 'username', 'password', 'remember_token')
|
||||
->where('username', $request->username)
|
||||
->get();
|
||||
|
||||
$login_ok = false;
|
||||
|
||||
try {
|
||||
$check_password = hash('sha256', $request->password . $getUser[0]->salt);
|
||||
|
||||
for ($round = 0; $round < 65536; $round++) {
|
||||
$check_password = hash('sha256', $check_password . $getUser[0]->salt);
|
||||
}
|
||||
|
||||
if ($check_password === $getUser[0]->password) {
|
||||
$login_ok = true;
|
||||
|
||||
$credentials = array(
|
||||
"username" => $request->username,
|
||||
"password" => $check_password
|
||||
);
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt($credentials)) {
|
||||
return response()->json(['error' => 'invalid_credentials'], 401);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
return response()->json(['error' => 'could_not_create_token'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['token' => "Bearer $token"]);
|
||||
//return $_SERVER['HTTP_HOST'];
|
||||
// setcookie("username", $_POST['username'], time()+3600*24*30*72, "/", $_SERVER['HTTP_HOST'], false, true);
|
||||
// setcookie("password", $check_password, time()+3600*24*30*72, "/", $_SERVER['HTTP_HOST'], false, true);
|
||||
//$cookieU = $request->cookie('username', $request->username, time()+3600*24*30*72);
|
||||
//$cookieP = $request->cookie('password', $check_password, time()+3600*24*30*72);
|
||||
|
||||
//dd($cookieP);
|
||||
//dd($request);
|
||||
//dd($cookie->name));
|
||||
//return response('')
|
||||
//->cookie('username', $cookieU)
|
||||
//->cookie('password', $cookieP);
|
||||
}
|
||||
|
||||
return "bad";
|
||||
}
|
||||
catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function register(Request $request) { // /api/rpc/user/auth/register
|
||||
return;
|
||||
}
|
||||
|
||||
public function logout(Request $request) { // /api/rpc/user/auth/logout
|
||||
return;
|
||||
}
|
||||
|
||||
// public function passwordReset() {}
|
||||
// public function confirmReset() {}
|
||||
|
||||
// Owner
|
||||
public function countOwnersOfEntry($file_id) { // /api/rpc/user/owner/countownersofentry/id
|
||||
return DB::table('str_owners')
|
||||
|
|
新しいイシューから参照