File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11# Change Log
22
3+ ### 3.0.6
4+
5+ * Added: RememberMe body parameter for extending login token to 30 days rather than 1 day.
6+
37### 3.0.5
48
59* Changed: Extract JWT token generation to a public function so it can be used from other places.
Original file line number Diff line number Diff line change @@ -119,8 +119,8 @@ protected function authenticate(Request $request)
119119 }
120120 }
121121
122- public function createJwtTokenForLoggedInUser ($ authData ) : string {
123- $ expiry = new \DateTime ('now +1 day ' );
122+ public function createJwtTokenForLoggedInUser ($ authData, $ expiry = null ) : string {
123+ $ expiry = isset ( $ expiry ) ? $ expiry : new \DateTime ('now +1 day ' );
124124
125125 return JWT ::encode (
126126 [
@@ -170,10 +170,12 @@ public function registerRoutes(App $app)
170170 }
171171
172172 list ($ status , $ authData ) = $ self ->authenticate ($ request );
173+ $ rememberMe = $ request ->getParsedBodyParam ('rememberMe ' );
174+ $ expiry = $ rememberMe ? new \DateTime ('now +30 day ' ): new \DateTime ('now +1 day ' );
173175
174176 if ($ status ) {
175177 $ data = [
176- 'token ' => $ self ->createJwtTokenForLoggedInUser ($ authData )
178+ 'token ' => $ self ->createJwtTokenForLoggedInUser ($ authData, $ expiry )
177179 ];
178180
179181 return $ response
You can’t perform that action at this time.
0 commit comments