Passed
Branch master (7ed08e)
by IRFA
01:58
created
libraries/Auth.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
  * @link	https://github.com/irfaardy/ci3-login
6 6
  * @version	1.0.0
7 7
  */
8
-class Auth{
8
+class Auth {
9 9
 	
10 10
 	private $CI;
11 11
 
12
-	function __construct(){
12
+	function __construct() {
13 13
 		$this->CI = & get_instance();
14 14
 	}
15 15
 	/**
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
      * @param string $password
20 20
      * @return boolean
21 21
      */
22
-	public function verify($username,$password){
22
+	public function verify($username, $password) {
23 23
 		$get = $this->CI->user->getBy(['username' => $username]);
24
-		if(password_verify($password, $get->password)) {
24
+		if (password_verify($password, $get->password)) {
25 25
 			$user_datas = array(
26 26
 			        'user_id'  => $get->id,
27 27
 			        'logged_in' => TRUE,
28
-			        'login_token' => sha1($get->id.time().mt_rand(1000,9999))
28
+			        'login_token' => sha1($get->id.time().mt_rand(1000, 9999))
29 29
 			);
30 30
 			$this->CI->session->sess_regenerate();
31 31
 			$this->CI->session->set_userdata($user_datas);
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return boolean
42 42
      */
43
-	public function check(){
44
-		if($this->CI->session->logged_in) {
43
+	public function check() {
44
+		if ($this->CI->session->logged_in) {
45 45
 			return true;
46 46
 		} 
47 47
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return mixed
55 55
      */
56
-	public function user(){
57
-		if($this->check()) {
56
+	public function user() {
57
+		if ($this->check()) {
58 58
 			$get = $this->CI->user->getBy(['id' => $this->CI->session->user_id]);
59 59
 			return $get;
60 60
 		}
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return void
69 69
      */
70
-	public function logout(){
71
-		if(empty($this->CI->input->get('token'))){
70
+	public function logout() {
71
+		if (empty($this->CI->input->get('token'))) {
72 72
 			return redirect($_SERVER['HTTP_REFERER']);
73 73
 		}
74 74
 
75
-		if($this->CI->session->login_token === $this->CI->input->get('token')){
75
+		if ($this->CI->session->login_token === $this->CI->input->get('token')) {
76 76
 			$this->destroy();
77
-		} else{
77
+		} else {
78 78
 			return redirect($_SERVER['HTTP_REFERER']);
79 79
 		}
80 80
 	}
81 81
 
82
-	private function destroy(){
82
+	private function destroy() {
83 83
 		$this->CI->session->sess_regenerate(TRUE);
84 84
 		$this->CI->session->sess_destroy();
85 85
 		return redirect(base_url('login'));
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	* Mencegah guest untuk mengakses halaman
89 89
 	* @return void
90 90
 	*/
91
-	public function protect(){
92
-		if(!$this->check()){
91
+	public function protect() {
92
+		if (!$this->check()) {
93 93
 			$this->destroy();
94 94
 		}
95 95
 	}
Please login to merge, or discard this patch.