1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-21 03:17:05 +08:00
course-tencent-cloud/app/Http/Home/Controllers/AccountController.php
koogua dd99631f6e !33 开放登录阶段性合并
* Merge remote-tracking branch 'gitee/xiaochong0302/I280IZ' into xiaocho…
* 初步完成开放登录,待线上测试7
* Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into xiao…
* 初步完成开放登录,待线上测试6
* !30 开放登录线上测试5
* !29 开放登录线上测试5
* 初步完成开放登录,待线上测试5
* !28 开放登录线上测试4
* 初步完成开放登录,待线上测试4
* !27 开放登录线上测试3
* 初步完成开放登录,待线上测试3
* !26 开放登录线上测试2
* 初步完成开放登录,待线上测试2
* !25 开放登录线上测试
* 初步完成开放登录,待线上测试
* !22 验证更新h5支付
* Merge remote-tracking branch 'remotes/gitee/develop' into demo
* !20 验证更新h5支付
* Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou…
* !16 v1.2.0阶段性合并
* 删除调试断点代码
* 删除重复的signature方法
* Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou…
* demo后台增加统计
* !5 更新版本号1.1.0
* !4 v1.1.0版本develop->demo
* Merge branch 'develop' into demo
* 1.增加changelog.md
* Merge branch 'develop' into demo
* Merge branch 'develop' into demo
* Merge branch 'develop' into demo
* !1 精简优化代码
* Merge branch 'develop' into demo
* 合并修改
2020-12-07 11:02:13 +08:00

215 lines
5.2 KiB
PHP

<?php
namespace App\Http\Home\Controllers;
use App\Http\Home\Services\Account as AccountService;
use App\Services\Logic\Account\EmailUpdate as EmailUpdateService;
use App\Services\Logic\Account\OAuthProvider as OAuthProviderService;
use App\Services\Logic\Account\PasswordReset as PasswordResetService;
use App\Services\Logic\Account\PasswordUpdate as PasswordUpdateService;
use App\Services\Logic\Account\PhoneUpdate as PhoneUpdateService;
class AccountController extends Controller
{
/**
* @Get("/register", name="home.account.register")
*/
public function registerAction()
{
if ($this->authUser->id > 0) {
$this->response->redirect('/');
}
$returnUrl = $this->request->getHTTPReferer();
$service = new AccountService();
$captcha = $service->getSettings('captcha');
$this->view->setVar('return_url', $returnUrl);
$this->view->setVar('captcha', $captcha);
}
/**
* @Post("/register", name="home.account.do_register")
*/
public function doRegisterAction()
{
$service = new AccountService();
$service->register();
$returnUrl = $this->request->getPost('return_url', 'string');
$content = [
'location' => $returnUrl ?: '/',
'msg' => '注册成功',
];
return $this->jsonSuccess($content);
}
/**
* @Get("/login", name="home.account.login")
*/
public function loginAction()
{
if ($this->authUser->id > 0) {
$this->response->redirect('/');
}
$service = new AccountService();
$captcha = $service->getSettings('captcha');
$service = new OAuthProviderService();
$oauthProvider = $service->handle();
$returnUrl = $this->request->getHTTPReferer();
$this->view->setVar('oauth_provider', $oauthProvider);
$this->view->setVar('return_url', $returnUrl);
$this->view->setVar('captcha', $captcha);
}
/**
* @Post("/password/login", name="home.account.pwd_login")
*/
public function loginByPasswordAction()
{
$service = new AccountService();
$service->loginByPassword();
$returnUrl = $this->request->getPost('return_url', 'string');
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
}
/**
* @Post("/verify/login", name="home.account.verify_login")
*/
public function loginByVerifyAction()
{
$service = new AccountService();
$service->loginByVerify();
$returnUrl = $this->request->getPost('return_url', 'string');
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
}
/**
* @Get("/logout", name="home.account.logout")
*/
public function logoutAction()
{
$service = new AccountService();
$service->logout();
$this->response->redirect(['for' => 'home.index']);
}
/**
* @Get("/password/forget", name="home.account.forget_pwd")
*/
public function forgetPasswordAction()
{
if ($this->authUser->id > 0) {
$this->response->redirect(['for' => 'home.index']);
}
$service = new AccountService();
$captcha = $service->getSettings('captcha');
$this->view->pick('account/forget_password');
$this->view->setVar('captcha', $captcha);
}
/**
* @Post("/password/reset", name="home.account.reset_pwd")
*/
public function resetPasswordAction()
{
$service = new PasswordResetService();
$service->handle();
$loginUrl = $this->url->get(['for' => 'home.account.login']);
$content = [
'location' => $loginUrl,
'msg' => '重置密码成功',
];
return $this->jsonSuccess($content);
}
/**
* @Post("/phone/update", name="home.account.update_phone")
*/
public function updatePhoneAction()
{
$service = new PhoneUpdateService();
$service->handle();
$location = $this->url->get(['for' => 'home.uc.account']);
$content = [
'location' => $location,
'msg' => '更新手机成功',
];
return $this->jsonSuccess($content);
}
/**
* @Post("/email/update", name="home.account.update_email")
*/
public function updateEmailAction()
{
$service = new EmailUpdateService();
$service->handle();
$location = $this->url->get(['for' => 'home.uc.account']);
$content = [
'location' => $location,
'msg' => '更新邮箱成功',
];
return $this->jsonSuccess($content);
}
/**
* @Post("/password/update", name="home.account.update_pwd")
*/
public function updatePasswordAction()
{
$service = new PasswordUpdateService();
$service->handle();
$location = $this->url->get(['for' => 'home.uc.account']);
$content = [
'location' => $location,
'msg' => '更新密码成功',
];
return $this->jsonSuccess($content);
}
}