Compare commits
3 Commits
0.2.0-pre2
...
master
Author | SHA1 | Date |
---|---|---|
Kekskurse | 0a7b27b506 | |
Kekskurse | d668b82fc6 | |
Kekskurse | 8ff1dee767 |
|
@ -208,6 +208,31 @@ class AppController extends BaseController
|
|||
|
||||
return $response->withData(["url" => $result['ObjectURL']]);
|
||||
}
|
||||
public function getAppIcon($id) {
|
||||
$app = \App\Models\App::query()->where("id", "=", $id)->firstOrFail();
|
||||
|
||||
if(!is_dir(storage_path("icon"))) {
|
||||
mkdir(storage_path("icon"));
|
||||
}
|
||||
|
||||
$cacheFile = storage_path("icon/".$app->id.".png");
|
||||
|
||||
if(file_exists($cacheFile)) {
|
||||
$icon = file_get_contents($cacheFile);
|
||||
} else {
|
||||
if(!empty($app->iconURL)) {
|
||||
$icon = file_get_contents($app->iconURL);
|
||||
file_put_contents($cacheFile, $icon);
|
||||
} else {
|
||||
$icon = file_get_contents(resource_path("images/app.png"));
|
||||
}
|
||||
}
|
||||
|
||||
$r = getimagesizefromstring($icon);
|
||||
|
||||
return response($icon)
|
||||
->header('Content-Type',$r["mime"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class UserController extends BaseController
|
|||
return $response->withData(new AccessToken($token));
|
||||
}
|
||||
|
||||
public function checkPassword(Request $request, Response $response) {
|
||||
public function checkPassword(Request $request, Response $response, Client $statsd) {
|
||||
//Validate Input
|
||||
$this->validate($request, [
|
||||
'username' => 'required',
|
||||
|
@ -91,13 +91,16 @@ class UserController extends BaseController
|
|||
|
||||
//Check if a user is found
|
||||
if($user == null) {
|
||||
$statsd->count("pwcheck.user_wrong", 1);
|
||||
throw new HTTPException("400", "Username or Password wrong");
|
||||
}
|
||||
|
||||
if(!password_verify($request->input("password"), $user->password)) {
|
||||
$statsd->count("pwcheck.password_wrong", 1);
|
||||
throw new HTTPException("400", "Username or Password wrong");
|
||||
}
|
||||
|
||||
$statsd->count("pwcheck.ok", 1);
|
||||
$response->setMessage("Account ok");
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../../../Dockerfile-app
|
|
@ -58,6 +58,7 @@ $router->group(['prefix' => 'api'], function () use ($router) {
|
|||
$router->post("/", ['uses' => 'API\AppController@createApp']);
|
||||
$router->get("/find", ['uses' => 'API\AppController@findApp']);
|
||||
$router->group(['prefix' => '{id}'], function () use ($router) {
|
||||
$router->get("/icon", ["uses" => "API\AppController@getAppIcon"]);
|
||||
$router->get("/", ['uses' => 'API\AppController@appDetails']);
|
||||
$router->put("/", ['uses' => 'API\AppController@updateApp']);
|
||||
$router->get("/access", ["uses" => "API\oAuthController@getAccess"]);
|
||||
|
|
Loading…
Reference in New Issue