Auth.php 979 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace addons\cos\library;
  3. class Auth
  4. {
  5. public function __construct()
  6. {
  7. }
  8. public static function isModuleAllow()
  9. {
  10. $config = get_addon_config('cos');
  11. $module = request()->module();
  12. $module = $module ? strtolower($module) : 'index';
  13. $noNeedLogin = array_filter(explode(',', $config['noneedlogin'] ?? ''));
  14. $isModuleLogin = false;
  15. $tagName = 'upload_config_checklogin';
  16. foreach (\think\Hook::get($tagName) as $index => $name) {
  17. if (\think\Hook::exec($name, $tagName)) {
  18. $isModuleLogin = true;
  19. break;
  20. }
  21. }
  22. if (in_array($module, $noNeedLogin)
  23. || ($module == 'admin' && \app\admin\library\Auth::instance()->id)
  24. || ($module != 'admin' && \app\common\library\Auth::instance()->id)
  25. || $isModuleLogin) {
  26. return true;
  27. } else {
  28. return false;
  29. }
  30. }
  31. }