Skip to content

Commit 6311f01

Browse files
committed
Update TraitAuthenticatable.php
1 parent d1f0dc1 commit 6311f01

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/Framework/inc/TraitAuthenticatable.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,34 @@ protected function isValidSession() : bool
4343
return ( $this->isSessionRegistered()
4444
&& !$this->isSessionExpired() );
4545
}
46-
46+
4747
/**
48-
* Get token access.
48+
* Get access token.
4949
*
5050
* @access protected
5151
* @param string $token
5252
* @param string $secret
5353
* @return array
5454
*/
55-
protected function getTokenAccess(string $token, ?string $secret = null) : array
55+
protected function getAccessToken(string $token, ?string $secret = null) : array
5656
{
5757
$encryption = new Encryption($token, $secret);
58-
return (array)$encryption->decrypt();
58+
return $encryption->setPrefix()->decrypt() ?: [];
59+
}
60+
61+
/**
62+
* Set access token.
63+
*
64+
* @access protected
65+
* @param string $user
66+
* @param string $pswd
67+
* @param string $secret
68+
* @return string
69+
*/
70+
protected function setAccessToken(string $user, string $pswd, ?string $secret = null) : string
71+
{
72+
$data = ['user' => $user, 'pswd' => $pswd];
73+
$encryption = new Encryption($data, $secret);
74+
return $encryption->setPrefix()->encrypt();
5975
}
6076
}

0 commit comments

Comments
 (0)