aboutsummaryrefslogtreecommitdiff
path: root/src/CamilStaps/BotleaguesApi/User.php
diff options
context:
space:
mode:
authorCamil Staps2015-05-12 18:35:07 +0200
committerCamil Staps2015-05-12 18:35:07 +0200
commitac28498d8b96733dfa679ec86371aaa6825d3079 (patch)
treed6f6e5094e20fb4ee197830aa7dac7988e0ad279 /src/CamilStaps/BotleaguesApi/User.php
parentCleanup; show user_token-token field on store request (POST) (diff)
Authentication with tokens
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/User.php')
-rw-r--r--src/CamilStaps/BotleaguesApi/User.php52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/CamilStaps/BotleaguesApi/User.php b/src/CamilStaps/BotleaguesApi/User.php
index 161d285..39b42dc 100644
--- a/src/CamilStaps/BotleaguesApi/User.php
+++ b/src/CamilStaps/BotleaguesApi/User.php
@@ -1,9 +1,10 @@
<?php
namespace CamilStaps\BotleaguesApi;
+use Illuminate\Auth\UserInterface;
use Illuminate\Database\Eloquent\Model;
-class User extends Model {
+class User extends Model implements UserInterface {
protected $table = 'users';
protected $hidden = ['password', 'remember_token', 'api_key'];
@@ -13,4 +14,53 @@ class User extends Model {
return (bool) $this->isAdministrator;
}
+ public function validToken($token) {
+ return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0;
+ }
+
+ /**
+ * Get the unique identifier for the user.
+ *
+ * @return mixed
+ */
+ public function getAuthIdentifier() {
+ return $this->email;
+ }
+
+ /**
+ * Get the password for the user.
+ *
+ * @return string
+ */
+ public function getAuthPassword() {
+ return null;
+ }
+
+ /**
+ * Get the token value for the "remember me" session.
+ *
+ * @return string
+ */
+ public function getRememberToken() {
+ return null;
+ }
+
+ /**
+ * Set the token value for the "remember me" session.
+ *
+ * @param string $value
+ * @return void
+ */
+ public function setRememberToken($value) {
+ return null;
+ }
+
+ /**
+ * Get the column name for the "remember me" token.
+ *
+ * @return string
+ */
+ public function getRememberTokenName() {
+ return null;
+ }
} \ No newline at end of file