mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-30 08:37:59 +01:00
30 lines
No EOL
780 B
PHP
30 lines
No EOL
780 B
PHP
<?php
|
|
|
|
namespace Api\Web;
|
|
|
|
use Commands\RegisterUserCommand;
|
|
|
|
class AuthController extends \Controller {
|
|
public function postLogin() {
|
|
if (!\Auth::attempt(array('email' => \Input::get('email'), 'password' => \Input::get('password')), \Input::get('remember')))
|
|
return \Response::json(['messages' => ['username' => 'Invalid username or password']], 400);
|
|
|
|
return \Response::json(['user' => \Auth::user()]);
|
|
}
|
|
|
|
public function postLogout() {
|
|
\Auth::logout();
|
|
}
|
|
|
|
public function postRegister() {
|
|
$command = new RegisterUserCommand();
|
|
if (!$command->authorize())
|
|
return \Response::json([], 403);
|
|
|
|
$errors = $command->validate();
|
|
if ($errors->fails())
|
|
return \Response::json([], 400);
|
|
|
|
return \Response::json($command->execute());
|
|
}
|
|
} |