aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorMarvin Borner2018-07-07 00:20:06 +0200
committerMarvin Borner2018-07-07 00:20:06 +0200
commit60c973ed2a8e58cc7e9d7e6ca69e17f6ec023c32 (patch)
treebf6ffd3d655e3be3a5d7b18696cacfb107427861 /app
parentefe4b98e6f3d5d63bc2da8110f474d6b7ec122df (diff)
Began public key "API"
Diffstat (limited to 'app')
-rw-r--r--app/Http/Controllers/PublicKeyController.php17
-rw-r--r--app/User.php7
2 files changed, 22 insertions, 2 deletions
diff --git a/app/Http/Controllers/PublicKeyController.php b/app/Http/Controllers/PublicKeyController.php
new file mode 100644
index 0000000..4fbdd64
--- /dev/null
+++ b/app/Http/Controllers/PublicKeyController.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Support\Facades\DB;
+
+class PublicKeyController extends Controller
+{
+ public function getUsersKey($user_id)
+ {
+ $public_key = DB::table('public_keys')
+ ->where('user_id', $user_id)
+ ->value('key');
+ // TODO: Friends: do not allow to request every public key
+ return $public_key ? $public_key : abort(404);
+ }
+}
diff --git a/app/User.php b/app/User.php
index 870d27c..4d6d0ee 100644
--- a/app/User.php
+++ b/app/User.php
@@ -1,7 +1,9 @@
<?php
namespace App;
-use Illuminate\Notifications\Notifiable;
+
use Illuminate\Foundation\Auth\User as Authenticatable;
+use Illuminate\Notifications\Notifiable;
+
class User extends Authenticatable
{
use Notifiable;
@@ -13,6 +15,7 @@ class User extends Authenticatable
protected $fillable = [
'name', 'email', 'password',
];
+
/**
* The attributes that should be hidden for arrays.
*
@@ -21,4 +24,4 @@ class User extends Authenticatable
protected $hidden = [
'password', 'remember_token',
];
-} \ No newline at end of file
+}