Completed
Push — master ( 54a5b3...49c9ad )
by Vojta
02:19
created
components/CodeLogin.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -16,110 +16,110 @@
 block discarded – undo
16 16
 
17 17
 class CodeLogin extends ComponentBase
18 18
 {
19
-    public function componentDetails()
20
-    {
21
-        return [
22
-            'name'        => 'vojtasvoboda.codelogin::lang.logincomponent.name',
23
-            'description' => 'vojtasvoboda.codelogin::lang.logincomponent.description'
24
-        ];
25
-    }
26
-
27
-    public function defineProperties()
28
-    {
29
-        return [
30
-            'redirect' => [
31
-                'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.redirect.title',
32
-                'description' => 'vojtasvoboda.codelogin::lang.logincomponent.redirect.description',
33
-                'type'        => 'dropdown',
34
-                'default'     => ''
35
-            ],
36
-            'visible' => [
37
-                'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.visible.title',
38
-                'description' => 'vojtasvoboda.codelogin::lang.logincomponent.visible.description',
39
-                'type'        => 'checkbox',
40
-                'default'     => false
41
-            ],
42
-            'button' => [
43
-                'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.button.title',
44
-                'description' => 'vojtasvoboda.codelogin::lang.logincomponent.button.description',
45
-                'type'        => 'string',
46
-                'default'     => 'enter'
47
-            ]
48
-        ];
49
-    }
50
-
51
-    public function getRedirectOptions()
52
-    {
53
-        $default = [
54
-            '' => '- none -'
55
-        ];
56
-        $pages = Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName');
57
-
58
-        return $default + $pages;
59
-    }
60
-
61
-    /**
62
-     * Executed when this component is bound to a page or layout.
63
-     */
64
-    public function onRun()
65
-    {
66
-        $this->page['visible'] = $this->property('visible');
67
-        $this->page['button'] = $this->property('button');
68
-    }
69
-
70
-    /**
71
-     * Sign in the user
72
-     */
73
-    public function onCodesignin()
74
-    {
75
-        /*
19
+	public function componentDetails()
20
+	{
21
+		return [
22
+			'name'        => 'vojtasvoboda.codelogin::lang.logincomponent.name',
23
+			'description' => 'vojtasvoboda.codelogin::lang.logincomponent.description'
24
+		];
25
+	}
26
+
27
+	public function defineProperties()
28
+	{
29
+		return [
30
+			'redirect' => [
31
+				'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.redirect.title',
32
+				'description' => 'vojtasvoboda.codelogin::lang.logincomponent.redirect.description',
33
+				'type'        => 'dropdown',
34
+				'default'     => ''
35
+			],
36
+			'visible' => [
37
+				'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.visible.title',
38
+				'description' => 'vojtasvoboda.codelogin::lang.logincomponent.visible.description',
39
+				'type'        => 'checkbox',
40
+				'default'     => false
41
+			],
42
+			'button' => [
43
+				'title'       => 'vojtasvoboda.codelogin::lang.logincomponent.button.title',
44
+				'description' => 'vojtasvoboda.codelogin::lang.logincomponent.button.description',
45
+				'type'        => 'string',
46
+				'default'     => 'enter'
47
+			]
48
+		];
49
+	}
50
+
51
+	public function getRedirectOptions()
52
+	{
53
+		$default = [
54
+			'' => '- none -'
55
+		];
56
+		$pages = Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName');
57
+
58
+		return $default + $pages;
59
+	}
60
+
61
+	/**
62
+	 * Executed when this component is bound to a page or layout.
63
+	 */
64
+	public function onRun()
65
+	{
66
+		$this->page['visible'] = $this->property('visible');
67
+		$this->page['button'] = $this->property('button');
68
+	}
69
+
70
+	/**
71
+	 * Sign in the user
72
+	 */
73
+	public function onCodesignin()
74
+	{
75
+		/*
76 76
          * Validate input
77 77
          */
78
-        $data = post();
78
+		$data = post();
79 79
 
80
-        $rules = [];
81
-        $rules['code'] = 'required|min:2';
80
+		$rules = [];
81
+		$rules['code'] = 'required|min:2';
82 82
 
83
-        $messages = [];
84
-        $messages['required'] = trans('vojtasvoboda.codelogin::lang.form.required');
83
+		$messages = [];
84
+		$messages['required'] = trans('vojtasvoboda.codelogin::lang.form.required');
85 85
 
86
-        $validation = Validator::make($data, $rules, $messages);
87
-        if ($validation->fails()) {
88
-            throw new ValidationException($validation);
89
-        }
86
+		$validation = Validator::make($data, $rules, $messages);
87
+		if ($validation->fails()) {
88
+			throw new ValidationException($validation);
89
+		}
90 90
 
91
-        /*
91
+		/*
92 92
          * Find user by password
93 93
          */
94
-        $users = new UserRepository();
95
-        $userToLog = $users->getUserByPassword(array_get($data, 'code'));
96
-        if ($userToLog === null) {
97
-            $exception = new ValidationException([trans('vojtasvoboda.codelogin::lang.form.wrong_code')]);
98
-            throw $exception;
99
-        }
100
-
101
-        /*
94
+		$users = new UserRepository();
95
+		$userToLog = $users->getUserByPassword(array_get($data, 'code'));
96
+		if ($userToLog === null) {
97
+			$exception = new ValidationException([trans('vojtasvoboda.codelogin::lang.form.wrong_code')]);
98
+			throw $exception;
99
+		}
100
+
101
+		/*
102 102
          * Authenticate user
103 103
          */
104
-        $remember = true;
105
-        $user = Auth::authenticate([
106
-            'login' => $userToLog->email,
107
-            'password' => array_get($data, 'code')
108
-        ], $remember);
104
+		$remember = true;
105
+		$user = Auth::authenticate([
106
+			'login' => $userToLog->email,
107
+			'password' => array_get($data, 'code')
108
+		], $remember);
109 109
 
110
-        /*
110
+		/*
111 111
          * After login event
112 112
          */
113
-        Event::fire('vojtasvoboda.codelogin.afterlogin', [$user]);
113
+		Event::fire('vojtasvoboda.codelogin.afterlogin', [$user]);
114 114
 
115
-        /*
115
+		/*
116 116
          * Redirect to the intended page after successful sign in
117 117
          */
118
-        $redirectUrl = $this->pageUrl($this->property('redirect'));
118
+		$redirectUrl = $this->pageUrl($this->property('redirect'));
119 119
 
120
-        if ($redirectUrl = post('redirect', $redirectUrl)) {
121
-            return Redirect::intended($redirectUrl);
122
-        }
123
-    }
120
+		if ($redirectUrl = post('redirect', $redirectUrl)) {
121
+			return Redirect::intended($redirectUrl);
122
+		}
123
+	}
124 124
 
125 125
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function onRun()
65 65
     {
66
-        $this->page['visible'] = $this->property('visible');
67
-        $this->page['button'] = $this->property('button');
66
+        $this->page[ 'visible' ] = $this->property('visible');
67
+        $this->page[ 'button' ] = $this->property('button');
68 68
     }
69 69
 
70 70
     /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
          */
78 78
         $data = post();
79 79
 
80
-        $rules = [];
81
-        $rules['code'] = 'required|min:2';
80
+        $rules = [ ];
81
+        $rules[ 'code' ] = 'required|min:2';
82 82
 
83
-        $messages = [];
84
-        $messages['required'] = trans('vojtasvoboda.codelogin::lang.form.required');
83
+        $messages = [ ];
84
+        $messages[ 'required' ] = trans('vojtasvoboda.codelogin::lang.form.required');
85 85
 
86 86
         $validation = Validator::make($data, $rules, $messages);
87 87
         if ($validation->fails()) {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $users = new UserRepository();
95 95
         $userToLog = $users->getUserByPassword(array_get($data, 'code'));
96 96
         if ($userToLog === null) {
97
-            $exception = new ValidationException([trans('vojtasvoboda.codelogin::lang.form.wrong_code')]);
97
+            $exception = new ValidationException([ trans('vojtasvoboda.codelogin::lang.form.wrong_code') ]);
98 98
             throw $exception;
99 99
         }
100 100
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         /*
111 111
          * After login event
112 112
          */
113
-        Event::fire('vojtasvoboda.codelogin.afterlogin', [$user]);
113
+        Event::fire('vojtasvoboda.codelogin.afterlogin', [ $user ]);
114 114
 
115 115
         /*
116 116
          * Redirect to the intended page after successful sign in
Please login to merge, or discard this patch.