1 | <?php |
||||
2 | |||||
3 | namespace Dynamic\Foxy\SingleSignOn\Controller; |
||||
4 | |||||
5 | use Dynamic\Foxy\Model\FoxyHelper; |
||||
6 | use SilverStripe\Control\Controller; |
||||
7 | use SilverStripe\Security\Member; |
||||
8 | use SilverStripe\Security\Security; |
||||
9 | |||||
10 | /** |
||||
11 | * Class SingleSignOnController |
||||
12 | * @package Dynamic\Foxy\SingleSignOn\Controller |
||||
13 | */ |
||||
14 | class SingleSignOnController extends Controller |
||||
15 | { |
||||
16 | /** |
||||
17 | * @var array |
||||
18 | */ |
||||
19 | private static $url_handlers = [ |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
20 | '' => 'sso', |
||||
21 | ]; |
||||
22 | |||||
23 | /** |
||||
24 | * @var array |
||||
25 | */ |
||||
26 | private static $allowed_actions = [ |
||||
0 ignored issues
–
show
|
|||||
27 | 'sso', |
||||
28 | ]; |
||||
29 | |||||
30 | /** |
||||
31 | * @param $request |
||||
32 | */ |
||||
33 | public function sso($request) |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
34 | { |
||||
35 | // GET variables from FoxyCart Request |
||||
36 | $fcsid = $this->request->getVar('fcsid'); |
||||
37 | $timestampNew = strtotime('+30 days'); |
||||
38 | $helper = FoxyHelper::create(); |
||||
39 | |||||
40 | // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
||||
41 | // fake user will redirect to FC checkout, ask customer to log in |
||||
42 | // to do: consider a login/registration form here if not logged in |
||||
43 | if (!$Member = Security::getCurrentUser()) { |
||||
44 | $Member = new Member(); |
||||
45 | $Member->Customer_ID = 0; |
||||
46 | } |
||||
47 | |||||
48 | $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . $helper->getStoreSecret()); |
||||
49 | |||||
50 | $params = [ |
||||
51 | 'fc_auth_token' => $auth_token, |
||||
52 | 'fcsid' => $fcsid, |
||||
53 | 'fc_customer_id' => $Member->Customer_ID, |
||||
54 | 'timestamp' => $timestampNew, |
||||
55 | ]; |
||||
56 | |||||
57 | $httpQuery = http_build_query($params); |
||||
58 | |||||
59 | $this->redirect("{$helper::StoreURL()}/checkout?$httpQuery"); |
||||
60 | } |
||||
61 | } |
||||
62 |