-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserServices.php
More file actions
75 lines (59 loc) · 1.3 KB
/
Copy pathUserServices.php
File metadata and controls
75 lines (59 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace App\ServiceLayer;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;
use Carbon\Carbon;
use App\User;
use App\AuthToken;
use App\LoginActivity;
/**
*
*/
class UserServices
{
/*
Check if user already exists
*/
public function UserExistService($request)
{
$user = new User();
return $user->userExist($request);
}
/*
Create a new user
*/
public function CreateUser($request)
{
$user = new User();
return $user->NewUser($request);
}
/*
User Authentication
*/
public function UserAuth($id, $token, $module)
{
$auth = new AuthToken();
$user = new User();
$login = new LoginActivity();
$loginTime = Carbon::now()->toDateTimeString();
$expiry = Carbon::parse('+1 year')->toDateTimeString();
$login_id = $login->UserLogin($id, $module, $loginTime);
$user->UserTokenUpdate($id, $token);
return $auth->UserToken($id, $token, $expiry, $login_id->login_activity_id);
}
/*
Logout functionality
*/
public function UserLogout($id, $autoExpired)
{
$auth = new AuthToken();
$user = new User();
$login = new LoginActivity();
$logoutTime = Carbon::now()->toDateTimeString();
$logout1 = $auth->UserLogout($id, $autoExpired);
$logout2 = $user->UserLogout($id);
$logout3 = $login->UserLogout($id, $logoutTime);
return true;
}
}