@@ -131,7 +131,6 @@ public function process(): \Illuminate\Database\Eloquent\Model
131131 $ this ->authProcess ();
132132 $ this ->checkRemember ();
133133 $ this ->clearActiveUsers ();
134- $ this ->writeLog ();
135134
136135 if ($ this ->events ) {
137136 // invoke OnManagerLogin event
@@ -179,28 +178,36 @@ public function validateAuth(): bool
179178
180179 // this user has been blocked by an admin, so no way he's loggin in!
181180 if ($ this ->user ->attributes ->blocked == '1 ' ) {
182- @session_destroy ();
183- session_unset ();
181+ if (!defined ('NO_SESSION ' )) {
182+ @session_destroy ();
183+ session_unset ();
184+ }
184185 throw new ServiceActionException (\Lang::get ('global.login_processor_blocked1 ' ));
185186 }
186187
187188 if ($ this ->user ->attributes ->verified != 1 ) {
188- @session_destroy ();
189- session_unset ();
189+ if (!defined ('NO_SESSION ' )) {
190+ @session_destroy ();
191+ session_unset ();
192+ }
190193 throw new ServiceActionException (\Lang::get ('global.login_processor_verified ' ));
191194 }
192195
193196 // blockuntil: this user has a block until date
194197 if ($ this ->user ->attributes ->blockeduntil > time ()) {
195- @session_destroy ();
196- session_unset ();
198+ if (!defined ('NO_SESSION ' )) {
199+ @session_destroy ();
200+ session_unset ();
201+ }
197202 throw new ServiceActionException (\Lang::get ('global.login_processor_blocked2 ' ));
198203 }
199204
200205 // blockafter: this user has a block after date
201206 if ($ this ->user ->attributes ->blockedafter > 0 && $ this ->user ->attributes ->blockedafter < time ()) {
202- @session_destroy ();
203- session_unset ();
207+ if (!defined ('NO_SESSION ' )) {
208+ @session_destroy ();
209+ session_unset ();
210+ }
204211 throw new ServiceActionException (\Lang::get ('global.login_processor_blocked2 ' ));
205212 }
206213
@@ -233,7 +240,29 @@ public function authProcess()
233240
234241 EvolutionCMS ()->cleanupExpiredLocks ();
235242 EvolutionCMS ()->cleanupMultipleActiveUsers ();
243+ if (!defined ('NO_SESSION ' )) {
244+ $ this ->writeSession ();
245+ }
246+ // successful login so reset fail count and update key values
247+ $ this ->user ->attributes ->failedlogincount = 0 ;
248+ $ this ->user ->attributes ->logincount += 1 ;
249+ $ this ->user ->attributes ->thislogin = time ();
250+ $ this ->user ->attributes ->lastlogin = time ();
251+ $ this ->user ->attributes ->save ();
252+
253+ $ this ->user ->refresh_token = hash ('sha256 ' , Str::random (32 ));
254+ $ this ->user ->access_token = hash ('sha256 ' , Str::random (32 ));
255+ $ this ->user ->valid_to = Carbon::now ()->addHours (11 );
256+ $ this ->user ->save ();
257+
258+ // get user's document groups
259+ $ i = 0 ;
260+
236261
262+ }
263+
264+ public function writeSession ()
265+ {
237266 $ currentsessionid = session_regenerate_id ();
238267
239268 $ _SESSION ['usertype ' ] = 'manager ' ; // user is a backend user
@@ -258,21 +287,7 @@ public function authProcess()
258287 }
259288 $ _SESSION ['mgrPermissions ' ] = $ permissionsRole ;
260289 }
261- // successful login so reset fail count and update key values
262- $ this ->user ->attributes ->failedlogincount = 0 ;
263- $ this ->user ->attributes ->logincount += 1 ;
264- $ this ->user ->attributes ->thislogin = time ();
265- $ this ->user ->attributes ->lastlogin = time ();
266290 $ this ->user ->attributes ->sessionid = $ currentsessionid ;
267- $ this ->user ->attributes ->save ();
268-
269- $ this ->user ->refresh_token = hash ('sha256 ' , Str::random (32 ));
270- $ this ->user ->access_token = hash ('sha256 ' , Str::random (32 ));
271- $ this ->user ->valid_to = Carbon::now ()->addHours (11 );
272- $ this ->user ->save ();
273-
274- // get user's document groups
275- $ i = 0 ;
276291
277292 $ _SESSION ['mgrDocgroups ' ] = \EvolutionCMS \Models \MemberGroup::query ()
278293 ->join ('membergroup_access ' , 'membergroup_access.membergroup ' , '= ' , 'member_groups.user_group ' )
@@ -322,11 +337,6 @@ public function clearActiveUsers()
322337 }
323338 }
324339
325- public function writeLog ()
326- {
327- $ log = new \EvolutionCMS \Legacy \LogHandler ();
328- $ log ->initAndWriteLog ('Logged in ' , EvolutionCMS ()->getLoginUserID ('mgr ' ), $ _SESSION ['mgrShortname ' ], '58 ' , '- ' , 'EVO ' );
329- }
330340
331341 public function incrementFailedLoginCount (): void
332342 {
0 commit comments