12345678910111213141516171819202122232425 |
- <?php
- namespace App\Modules\Admin\Services;
- use App\Exceptions\ClientException;
- use App\Models\User;
- class AuthService
- {
- public function login($data)
- {
- $u = User::wherePhone($data['username'])->orWhere("email",$data['username'])->first();
- if(is_null($u)) {
- throw new ClientException("账号或密码错误,请重新输入");
- }
- if(!$u->checkPassword($data['password'])) {
- throw new ClientException("账号或密码错误,请重新输入!");
- }
- if($u->status != User::STATUS_OK) {
- throw new ClientException("当前用户被禁用,请联系管理员");
- }
- return $u;
- }
- }
|