-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from orvice/dev
add api
- Loading branch information
Showing
28 changed files
with
580 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
|
||
class Token extends Model | ||
{ | ||
protected $table = "user_token"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Services\Auth; | ||
|
||
|
||
abstract class Base | ||
{ | ||
abstract public function login($uid,$time); | ||
abstract public function logout(); | ||
abstract public function getUser(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Services\Auth; | ||
|
||
use App\Utils; | ||
use App\Services\Jwt; | ||
|
||
class JwtToken extends Base | ||
{ | ||
public function login($uid, $time) | ||
{ | ||
$expireTime = time() + $time; | ||
$ary = [ | ||
"uid" => $uid, | ||
"expire_time" => $expireTime | ||
]; | ||
$decode = Jwt::encode($ary); | ||
Utils\Cookie::set([ | ||
//"uid" => $uid, | ||
"token" => $decode | ||
],$expireTime); | ||
} | ||
|
||
public function logout() | ||
{ | ||
Utils\Cookie::set([ | ||
//"uid" => $uid, | ||
"token" => "" | ||
],time()-3600); | ||
} | ||
|
||
public function getUser() | ||
{ | ||
$token = Utils\Cookie::get('token'); | ||
$tokenInfo = Jwt::decodeArray($token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.