|
@@ -30,11 +30,9 @@ use Str;
|
|
|
use Validator;
|
|
|
|
|
|
|
|
|
- * 认证控制器
|
|
|
+ * 认证控制器.
|
|
|
*
|
|
|
* Class AuthController
|
|
|
- *
|
|
|
- * @package App\Http\Controllers
|
|
|
*/
|
|
|
class AuthController extends Controller
|
|
|
{
|
|
@@ -65,17 +63,17 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
|
|
|
+ if (! Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
|
|
|
return Redirect::back()->withInput()->withErrors(trans('auth.login_error'));
|
|
|
}
|
|
|
$user = Auth::getUser();
|
|
|
|
|
|
- if (!$user) {
|
|
|
+ if (! $user) {
|
|
|
return Redirect::back()->withInput()->withErrors(trans('auth.login_error'));
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!$user->is_admin) {
|
|
|
+ if (! $user->is_admin) {
|
|
|
if ($user->status < 0) {
|
|
|
Auth::logout();
|
|
|
|
|
@@ -119,7 +117,7 @@ class AuthController extends Controller
|
|
|
{
|
|
|
switch (sysConfig('is_captcha')) {
|
|
|
case 1:
|
|
|
- if (!Captcha::check($request->input('captcha'))) {
|
|
|
+ if (! Captcha::check($request->input('captcha'))) {
|
|
|
return Redirect::back()->withInput()->withErrors(trans('auth.captcha_error'));
|
|
|
}
|
|
|
break;
|
|
@@ -160,7 +158,7 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 添加用户登录日志
|
|
|
+ * 添加用户登录日志.
|
|
|
*
|
|
|
* @param int $userId 用户ID
|
|
|
* @param string $ip IP地址
|
|
@@ -170,7 +168,7 @@ class AuthController extends Controller
|
|
|
$ipLocation = IP::getIPInfo($ip);
|
|
|
|
|
|
if (empty($ipLocation) || empty($ipLocation['country'])) {
|
|
|
- Log::warning("获取IP信息异常:".$ip);
|
|
|
+ Log::warning('获取IP信息异常:'.$ip);
|
|
|
}
|
|
|
|
|
|
$log = new UserLoginLog();
|
|
@@ -185,7 +183,6 @@ class AuthController extends Controller
|
|
|
$log->save();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
public function logout(): RedirectResponse
|
|
|
{
|
|
@@ -238,7 +235,7 @@ class AuthController extends Controller
|
|
|
Session::forget('register_token');
|
|
|
|
|
|
|
|
|
- if (!sysConfig('is_register')) {
|
|
|
+ if (! sysConfig('is_register')) {
|
|
|
return Redirect::back()->withErrors(trans('auth.register_close'));
|
|
|
}
|
|
|
|
|
@@ -264,12 +261,12 @@ class AuthController extends Controller
|
|
|
|
|
|
|
|
|
if (sysConfig('is_activate_account') == 1) {
|
|
|
- if (!$verify_code) {
|
|
|
+ if (! $verify_code) {
|
|
|
return Redirect::back()->withInput($request->except('verify_code'))->withErrors(trans('auth.captcha_null'));
|
|
|
}
|
|
|
|
|
|
$verifyCode = VerifyCode::whereAddress($email)->whereCode($verify_code)->whereStatus(0)->first();
|
|
|
- if (!$verifyCode) {
|
|
|
+ if (! $verifyCode) {
|
|
|
return Redirect::back()->withInput($request->except('verify_code'))->withErrors(trans('auth.captcha_overtime'));
|
|
|
}
|
|
|
|
|
@@ -307,7 +304,7 @@ class AuthController extends Controller
|
|
|
$uid = Helpers::addUser($email, $password, $transfer_enable, sysConfig('default_days'), $inviter_id);
|
|
|
|
|
|
|
|
|
- if (!$uid) {
|
|
|
+ if (! $uid) {
|
|
|
return Redirect::back()->withInput()->withErrors(trans('auth.register_fail'));
|
|
|
}
|
|
|
|
|
@@ -376,17 +373,17 @@ class AuthController extends Controller
|
|
|
return Redirect::back()->withErrors(trans('auth.email_banned'));
|
|
|
}
|
|
|
|
|
|
- return Response::json(['status' => 'fail', 'message' => trans('auth.email_banned'),]);
|
|
|
+ return Response::json(['status' => 'fail', 'message' => trans('auth.email_banned')]);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
- if (!in_array(strtolower($emailSuffix[1]), $emailFilterList, true)) {
|
|
|
+ if (! in_array(strtolower($emailSuffix[1]), $emailFilterList, true)) {
|
|
|
if ($returnType) {
|
|
|
return Redirect::back()->withErrors(trans('auth.email_invalid'));
|
|
|
}
|
|
|
|
|
|
- return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid'),]);
|
|
|
+ return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid')]);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -394,14 +391,14 @@ class AuthController extends Controller
|
|
|
return Redirect::back()->withErrors(trans('auth.email_invalid'));
|
|
|
}
|
|
|
|
|
|
- return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid'),]);
|
|
|
+ return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid')]);
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 获取AFF
|
|
|
+ * 获取AFF.
|
|
|
*
|
|
|
* @param string|null $code 邀请码
|
|
|
* @param int|null $aff URL中的aff参数
|
|
@@ -410,7 +407,7 @@ class AuthController extends Controller
|
|
|
*/
|
|
|
private function getAff($code = null, $aff = null): array
|
|
|
{
|
|
|
- $data = ['inviter_id' => null, 'code_id' => 0];
|
|
|
+ $data = ['inviter_id' => null, 'code_id' => 0];
|
|
|
|
|
|
|
|
|
if ($code) {
|
|
@@ -422,7 +419,7 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!$data['inviter_id']) {
|
|
|
+ if (! $data['inviter_id']) {
|
|
|
|
|
|
$cookieAff = \Request::hasCookie('register_aff') ? \Request::cookie('register_aff') : 0;
|
|
|
if ($cookieAff) {
|
|
@@ -468,13 +465,13 @@ class AuthController extends Controller
|
|
|
$email = $request->input('email');
|
|
|
|
|
|
|
|
|
- if (!sysConfig('is_reset_password')) {
|
|
|
+ if (! sysConfig('is_reset_password')) {
|
|
|
return Redirect::back()->withErrors(trans('auth.reset_password_close', ['email' => sysConfig('webmaster_email')]));
|
|
|
}
|
|
|
|
|
|
|
|
|
$user = User::whereEmail($email)->first();
|
|
|
- if (!$user) {
|
|
|
+ if (! $user) {
|
|
|
return Redirect::back()->withErrors(trans('auth.email_notExist'));
|
|
|
}
|
|
|
|
|
@@ -507,7 +504,7 @@ class AuthController extends Controller
|
|
|
|
|
|
public function reset(Request $request, $token)
|
|
|
{
|
|
|
- if (!$token) {
|
|
|
+ if (! $token) {
|
|
|
return Redirect::route('login');
|
|
|
}
|
|
|
|
|
@@ -531,7 +528,7 @@ class AuthController extends Controller
|
|
|
|
|
|
$verify = Verify::type(1)->whereToken($token)->first();
|
|
|
$user = $verify->user;
|
|
|
- if (!$verify) {
|
|
|
+ if (! $verify) {
|
|
|
return Redirect::route('login');
|
|
|
}
|
|
|
|
|
@@ -548,7 +545,7 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!$user->update(['password' => $password])) {
|
|
|
+ if (! $user->update(['password' => $password])) {
|
|
|
return Redirect::back()->withErrors(trans('auth.reset_password_fail'));
|
|
|
}
|
|
|
|
|
@@ -560,7 +557,7 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
$verify = Verify::type(1)->whereToken($token)->first();
|
|
|
- if (!$verify) {
|
|
|
+ if (! $verify) {
|
|
|
return Redirect::route('login');
|
|
|
}
|
|
|
|
|
@@ -638,13 +635,13 @@ class AuthController extends Controller
|
|
|
|
|
|
public function active($token)
|
|
|
{
|
|
|
- if (!$token) {
|
|
|
+ if (! $token) {
|
|
|
return Redirect::route('login');
|
|
|
}
|
|
|
|
|
|
$verify = Verify::type(1)->with('user')->whereToken($token)->first();
|
|
|
$user = $verify->user;
|
|
|
- if (!$verify) {
|
|
|
+ if (! $verify) {
|
|
|
return Redirect::route('login');
|
|
|
}
|
|
|
|
|
@@ -677,7 +674,7 @@ class AuthController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!$user->update(['status' => 1])) {
|
|
|
+ if (! $user->update(['status' => 1])) {
|
|
|
Session::flash('errorMsg', trans('auth.active_fail'));
|
|
|
|
|
|
return Redirect::back();
|
|
@@ -712,7 +709,7 @@ class AuthController extends Controller
|
|
|
$email = $request->input('email');
|
|
|
|
|
|
if ($validator->fails()) {
|
|
|
- return Response::json(['status' => 'fail', 'message' => $validator->getMessageBag()->first(),]);
|
|
|
+ return Response::json(['status' => 'fail', 'message' => $validator->getMessageBag()->first()]);
|
|
|
}
|
|
|
$ip = IP::getClientIP();
|
|
|
|
|
@@ -767,7 +764,7 @@ class AuthController extends Controller
|
|
|
|
|
|
public function switchLang($locale): RedirectResponse
|
|
|
{
|
|
|
- Session::put("locale", $locale);
|
|
|
+ Session::put('locale', $locale);
|
|
|
|
|
|
return Redirect::back();
|
|
|
}
|