Repository navigation
Expand file tree
/
Copy pathBotAuthInfo.php
More file actions
72 lines (67 loc) · 1.8 KB
/
Copy pathBotAuthInfo.php
File metadata and controls
72 lines (67 loc) · 1.8 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
<?php
/**
* Author: Arda Baran
*
* Description:
*
* This class manages the authentication information required by
* the ISS Chatbot services.
*
* The authentication data is stored in the Laravel session and
* can be accessed by other chatbot services whenever authentication
* credentials are required.
*
* The class provides three basic operations:
*
* 1) get()
* Retrieves the currently stored authentication information.
*
* 2) start()
* Initializes the authentication information and stores it
* in the current session.
*
* 3) clear()
* Removes the authentication information from the session.
*
* This class acts as a centralized authentication-state manager.
* Instead of storing authentication information independently in
* multiple services, chatbot services can use BotAuthInfo as a
* single source for the current authentication state.
*
* The general flow is:
*
* BotAuthInfo
* │
* ├── get() → Read authentication state
* │
* ├── start() → Initialize authentication state
* │
* └── clear() → Remove authentication state
*
* Other services such as DecisionActions and
* GetCustomerInfoFromOIM can use this class to access
* the current authentication information.
*/
namespace App\Services\bot;
class BotAuthInfo
{
protected const AUTH_SESSION_KEY = 'chatbot_auth';
public function get(): ?array
{
return session(self::AUTH_SESSION_KEY);
}
public function start(): void
{
session([
self::AUTH_SESSION_KEY => [
'username' => 'aaa',
'password' => 'bbb',
'musteri_api_key' => 'secret',
]
]);
}
public function clear(): void
{
session()->forget(self::AUTH_SESSION_KEY);
}
}