注册接口

This commit is contained in:
2025-05-05 20:23:01 +08:00
parent 91a1d06b53
commit c61357eca1
4 changed files with 153 additions and 130 deletions

View File

@@ -37,7 +37,7 @@ class LoginService
* @return array
* @throws Exception
*/
public function login($account, $password)
public function login($account, $password): array
{
$userModel = UserModel::with(['roles:id,name,value'])->where('account', $account)->first();
if (empty($userModel)) {
@@ -86,10 +86,12 @@ class LoginService
* 注册
* @param $account
* @param $password
* @param $email
* @param $code
* @return array
* @throws Exception
*/
public function register($account, $password): array
public function register($account, $password, $email, $code): array
{
$userModel = UserModel::where('account', $account)->first();
if ($userModel) {
@@ -98,6 +100,7 @@ class LoginService
$createModel = UserModel::create([
'account' => $account,
'email' => $email,
'password' => password_hash($password, PASSWORD_DEFAULT),
'nick_name' => '新用户'. Str::random(),
'avatar' => 'https://pic.rmb.bdstatic.com/bjh/80852bfe7c321988191838517ba64e309354.jpeg@h_1280',