AuthApi fix, refactoring
This commit is contained in:
		@@ -1,25 +1,25 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
class AuthApi {
 | 
					class AuthApi {
 | 
				
			||||||
    static function login(){
 | 
						public function login(){
 | 
				
			||||||
        $token = (new ApiManager)->getToken($this->input->username,$this->input->password);
 | 
							$token = (new ApiManager)->getToken($this->input->username,$this->input->password);
 | 
				
			||||||
        if (!$token) {
 | 
							if (!$token) {
 | 
				
			||||||
            throw new Exception("Auth failed", 401);
 | 
								throw new Exception("Auth failed", 401);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
        $this->response(['token' => $token]);
 | 
							$this->response(['token' => $token]);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static function logout(){
 | 
						public function logout(){
 | 
				
			||||||
        $authenticationBearrer = $_SERVER['HTTP_AUTHORIZATION'];
 | 
							$authenticationBearrer = $_SERVER['HTTP_AUTHORIZATION'];
 | 
				
			||||||
        if (!(new ApiManager)->deleteToken($authenticationBearrer)) {
 | 
							if (!(new ApiManager)->deleteToken($authenticationBearrer)) {
 | 
				
			||||||
            throw new Exception("logout Failed", 401);
 | 
								throw new Exception("logout Failed", 401);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static function registration(){
 | 
						public function registration(){
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static function restartPassword(){
 | 
						}
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    }
 | 
						public function restartPassword(){
 | 
				
			||||||
} 
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user