ConfigService.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\service\api\login;
  12. use app\dict\member\MemberLoginTypeDict;
  13. use app\service\api\member\MemberConfigService;
  14. use core\base\BaseApiService;
  15. use core\exception\AuthException;
  16. /**
  17. * 登录注册配置服务层
  18. * Class MemberService
  19. * @package app\service\api\member
  20. */
  21. class ConfigService extends BaseApiService
  22. {
  23. /**
  24. * 校验登录注册配置是否正确配置
  25. * @param string $type
  26. * @return true
  27. */
  28. public function checkLoginConfig(string $type)
  29. {
  30. //登录注册配置
  31. $config = ( new MemberConfigService() )->getLoginConfig();
  32. if ($type == MemberLoginTypeDict::USERNAME) {
  33. $is_username = $config[ 'is_username' ];
  34. //未开启账号密码登录注册
  35. if ($is_username != 1) throw new AuthException('MEMBER_USERNAME_LOGIN_NOT_OPEN');
  36. } elseif ($type == MemberLoginTypeDict::MOBILE) {
  37. $is_mobile = $config[ 'is_mobile' ];
  38. $is_bind_mobile = $config[ 'is_bind_mobile' ];
  39. //未开启手机号登录注册
  40. if ($is_mobile != 1 && $is_bind_mobile != 1) throw new AuthException('MOBILE_LOGIN_UNOPENED');
  41. }
  42. return true;
  43. }
  44. }