common.php 1011 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use ba\Filesystem;
  3. use app\admin\library\module\Server;
  4. if (!function_exists('get_account_verification_type')) {
  5. /**
  6. * 获取可用的账户验证方式
  7. * 用于:用户找回密码|用户注册
  8. * @return string[] email=电子邮件,mobile=手机短信验证
  9. * @throws Throwable
  10. */
  11. function get_account_verification_type(): array
  12. {
  13. $types = [];
  14. // 电子邮件,检查后台系统邮件配置是否全部填写
  15. $sysMailConfig = get_sys_config('', 'mail');
  16. $configured = true;
  17. foreach ($sysMailConfig as $item) {
  18. if (!$item) {
  19. $configured = false;
  20. }
  21. }
  22. if ($configured) {
  23. $types[] = 'email';
  24. }
  25. // 手机号,检查是否安装短信模块
  26. $sms = Server::getIni(Filesystem::fsFit(root_path() . 'modules/sms/'));
  27. if ($sms && $sms['state'] == 1) {
  28. $types[] = 'mobile';
  29. }
  30. return $types;
  31. }
  32. }