mirror of https://github.com/flucont/btcloud.git
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							26 lines
						
					
					
						
							724 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							26 lines
						
					
					
						
							724 B
						
					
					
				
								<?php
							 | 
						|
								declare (strict_types=1);
							 | 
						|
								
							 | 
						|
								namespace app\middleware;
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								class AuthAdmin
							 | 
						|
								{
							 | 
						|
								    public function handle($request, \Closure $next)
							 | 
						|
								    {
							 | 
						|
								        $islogin = false;
							 | 
						|
								        $cookie = cookie('admin_token');
							 | 
						|
								        if($cookie){
							 | 
						|
								            $token=authcode($cookie, 'DECODE', config_get('syskey'));
							 | 
						|
								            if($token){
							 | 
						|
								                list($user, $sid, $expiretime) = explode("\t", $token);
							 | 
						|
								                $session=md5(config_get('admin_username').config_get('admin_password'));
							 | 
						|
								                if($session==$sid && $expiretime>time()) {
							 | 
						|
								                    $islogin = true;
							 | 
						|
								                }
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								        request()->islogin = $islogin;
							 | 
						|
								        return $next($request);
							 | 
						|
								    }
							 | 
						|
								}
							 |