@@ -6,25 +6,25 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ResendEmailConfirmation extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'email' => 'required|exists:users,email' |
|
| 28 | - ]; |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'email' => 'required|exists:users,email' |
|
| 28 | + ]; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -6,28 +6,28 @@ |
||
| 6 | 6 | |
| 7 | 7 | class UpdateUser extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'id' => 'required|exists:users,id', |
|
| 28 | - 'name' => 'nullable|string', |
|
| 29 | - 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
| 30 | - 'password' => 'nullable|min:6' |
|
| 31 | - ]; |
|
| 32 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'id' => 'required|exists:users,id', |
|
| 28 | + 'name' => 'nullable|string', |
|
| 29 | + 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
| 30 | + 'password' => 'nullable|min:6' |
|
| 31 | + ]; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -6,28 +6,28 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ResetPassword extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'token' => 'required', |
|
| 28 | - 'email' => 'required|email', |
|
| 29 | - 'password' => 'required|confirmed|min:6', |
|
| 30 | - 'password_confirmation' => 'required', |
|
| 31 | - ]; |
|
| 32 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'token' => 'required', |
|
| 28 | + 'email' => 'required|email', |
|
| 29 | + 'password' => 'required|confirmed|min:6', |
|
| 30 | + 'password_confirmation' => 'required', |
|
| 31 | + ]; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Register extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'name' => 'nullable|string', |
|
| 28 | - 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
| 29 | - 'password' => 'required|min:6' |
|
| 30 | - ]; |
|
| 31 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'name' => 'nullable|string', |
|
| 28 | + 'email' => 'required|email|unique:users,email,'.$this->get('id'), |
|
| 29 | + 'password' => 'required|min:6' |
|
| 30 | + ]; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Login extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'email' => 'required|email', |
|
| 28 | - 'password' => 'required|min:6', |
|
| 29 | - 'admin' => 'nullable|boolean' |
|
| 30 | - ]; |
|
| 31 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'email' => 'required|email', |
|
| 28 | + 'password' => 'required|min:6', |
|
| 29 | + 'admin' => 'nullable|boolean' |
|
| 30 | + ]; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -6,26 +6,26 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AssignGroups extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'group_ids' => 'required|exists:groups,id', |
|
| 28 | - 'user_id' => 'required|exists:users,id' |
|
| 29 | - ]; |
|
| 30 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'group_ids' => 'required|exists:groups,id', |
|
| 28 | + 'user_id' => 'required|exists:users,id' |
|
| 29 | + ]; |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class LoginSocial extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'auth_code' => 'required_without:access_token', |
|
| 28 | - 'access_token' => 'required_without:auth_code', |
|
| 29 | - 'type' => 'required|in:facebook,google' |
|
| 30 | - ]; |
|
| 31 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'auth_code' => 'required_without:access_token', |
|
| 28 | + 'access_token' => 'required_without:auth_code', |
|
| 29 | + 'type' => 'required|in:facebook,google' |
|
| 30 | + ]; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -6,25 +6,25 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ConfirmEmail extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - 'confirmation_code' => 'required|string' |
|
| 28 | - ]; |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + 'confirmation_code' => 'required|string' |
|
| 28 | + ]; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -2,77 +2,77 @@ |
||
| 2 | 2 | |
| 3 | 3 | class LoginProxy |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Attempt to create an access token using user credentials. |
|
| 7 | - * |
|
| 8 | - * @param array $credentials |
|
| 9 | - * @param boolean $adminLogin |
|
| 10 | - * @return array |
|
| 11 | - */ |
|
| 12 | - public function login($credentials, $adminLogin = false) |
|
| 13 | - { |
|
| 14 | - $user = \Core::users()->login($credentials, $adminLogin); |
|
| 15 | - $tokens = $this->proxy('password', [ |
|
| 16 | - 'username' => $credentials['email'], |
|
| 17 | - 'password' => $credentials['password'] |
|
| 18 | - ]); |
|
| 5 | + /** |
|
| 6 | + * Attempt to create an access token using user credentials. |
|
| 7 | + * |
|
| 8 | + * @param array $credentials |
|
| 9 | + * @param boolean $adminLogin |
|
| 10 | + * @return array |
|
| 11 | + */ |
|
| 12 | + public function login($credentials, $adminLogin = false) |
|
| 13 | + { |
|
| 14 | + $user = \Core::users()->login($credentials, $adminLogin); |
|
| 15 | + $tokens = $this->proxy('password', [ |
|
| 16 | + 'username' => $credentials['email'], |
|
| 17 | + 'password' => $credentials['password'] |
|
| 18 | + ]); |
|
| 19 | 19 | |
| 20 | - return compact('user', 'tokens'); |
|
| 21 | - } |
|
| 20 | + return compact('user', 'tokens'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Attempt to refresh the access token useing the given refresh token. |
|
| 25 | - * |
|
| 26 | - * @param string $refreshToken |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function refreshToken($refreshToken) |
|
| 30 | - { |
|
| 31 | - return $this->proxy('refresh_token', [ |
|
| 32 | - 'refresh_token' => $refreshToken |
|
| 33 | - ]); |
|
| 34 | - } |
|
| 23 | + /** |
|
| 24 | + * Attempt to refresh the access token useing the given refresh token. |
|
| 25 | + * |
|
| 26 | + * @param string $refreshToken |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function refreshToken($refreshToken) |
|
| 30 | + { |
|
| 31 | + return $this->proxy('refresh_token', [ |
|
| 32 | + 'refresh_token' => $refreshToken |
|
| 33 | + ]); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Proxy a request to the OAuth server. |
|
| 38 | - * |
|
| 39 | - * @param string $grantType what type of grant type should be proxied |
|
| 40 | - * @param array |
|
| 41 | - */ |
|
| 42 | - public function proxy($grantType, array $data = []) |
|
| 43 | - { |
|
| 44 | - $data = array_merge($data, [ |
|
| 45 | - 'client_id' => config('skeleton.passport_client_id'), |
|
| 46 | - 'client_secret' => config('skeleton.passport_client_secret'), |
|
| 47 | - 'grant_type' => $grantType |
|
| 48 | - ]); |
|
| 36 | + /** |
|
| 37 | + * Proxy a request to the OAuth server. |
|
| 38 | + * |
|
| 39 | + * @param string $grantType what type of grant type should be proxied |
|
| 40 | + * @param array |
|
| 41 | + */ |
|
| 42 | + public function proxy($grantType, array $data = []) |
|
| 43 | + { |
|
| 44 | + $data = array_merge($data, [ |
|
| 45 | + 'client_id' => config('skeleton.passport_client_id'), |
|
| 46 | + 'client_secret' => config('skeleton.passport_client_secret'), |
|
| 47 | + 'grant_type' => $grantType |
|
| 48 | + ]); |
|
| 49 | 49 | |
| 50 | - $response = \ApiConsumer::post('/oauth/token', $data); |
|
| 50 | + $response = \ApiConsumer::post('/oauth/token', $data); |
|
| 51 | 51 | |
| 52 | - if (! $response->isSuccessful()) { |
|
| 53 | - if ($grantType == 'refresh_token') { |
|
| 54 | - \ErrorHandler::invalidRefreshToken(); |
|
| 55 | - } |
|
| 52 | + if (! $response->isSuccessful()) { |
|
| 53 | + if ($grantType == 'refresh_token') { |
|
| 54 | + \ErrorHandler::invalidRefreshToken(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - \ErrorHandler::loginFailed(); |
|
| 58 | - } |
|
| 57 | + \ErrorHandler::loginFailed(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $data = json_decode($response->getContent()); |
|
| 60 | + $data = json_decode($response->getContent()); |
|
| 61 | 61 | |
| 62 | - return [ |
|
| 63 | - 'access_token' => $data->access_token, |
|
| 64 | - 'refresh_token' => $data->refresh_token, |
|
| 65 | - 'expires_in' => $data->expires_in |
|
| 66 | - ]; |
|
| 67 | - } |
|
| 62 | + return [ |
|
| 63 | + 'access_token' => $data->access_token, |
|
| 64 | + 'refresh_token' => $data->refresh_token, |
|
| 65 | + 'expires_in' => $data->expires_in |
|
| 66 | + ]; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Logs out the user. We revoke access token and refresh token. |
|
| 71 | - * |
|
| 72 | - * @return void |
|
| 73 | - */ |
|
| 74 | - public function logout() |
|
| 75 | - { |
|
| 76 | - \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
| 77 | - } |
|
| 69 | + /** |
|
| 70 | + * Logs out the user. We revoke access token and refresh token. |
|
| 71 | + * |
|
| 72 | + * @return void |
|
| 73 | + */ |
|
| 74 | + public function logout() |
|
| 75 | + { |
|
| 76 | + \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | $response = \ApiConsumer::post('/oauth/token', $data); |
| 53 | 53 | |
| 54 | - if (! $response->isSuccessful()) { |
|
| 54 | + if ( ! $response->isSuccessful()) { |
|
| 55 | 55 | if ($grantType == 'refresh_token') { |
| 56 | 56 | \ErrorHandler::invalidRefreshToken(); |
| 57 | 57 | } |