Compare commits

...

3 Commits

Author SHA1 Message Date
Kekskurse 0a7b27b506 Dockerfile 2019-12-26 01:46:57 +01:00
Kekskurse d668b82fc6 Stuff 2019-12-25 19:38:37 +01:00
Kekskurse 8ff1dee767 Icon 2019-12-25 19:33:53 +01:00
4 changed files with 31 additions and 1 deletions

View File

@ -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"]);
}

View File

@ -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;

View File

@ -0,0 +1 @@
../../../Dockerfile-app

View File

@ -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"]);