Subversion Repositories SmartDukaan

Rev

Rev 15354 | Rev 16276 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
class Auth extends MY_Controller {
3
public $layoutName ='';
4
	function __construct() {
5
 
6
		// Call the CI_controller constructor
7
		parent::__construct();
11108 lgm 8
		// $admin = $this->session->userdata('admin');
9
		// if(!isset($admin) || empty($admin)) {
10
		// 	redirect(base_url().'authorize');
11
		// }
10582 lgm 12
		$this->output->set_header("HTTP/1.0 200 OK");
13
		$this->output->set_header("HTTP/1.1 200 OK");
14
		$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
15
		$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
16
		$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
17
		$this->output->set_header("Pragma: no-cache");
18
		$this->layout->setlayout('layout/layout_main');
19
		$this->load->model('oauth_model');
20
		$this->layoutName= $this->layout->getLayout();
21
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
22
 
23
 
24
 
25
	}
26
	public function index()
27
	{
28
		$this->__oauthorization();
29
 
30
 
31
	}
32
	function __oauthorization()
33
	{
34
		//sample session storage.. later i will imporve security for login 
35
		$check =$this->session->userdata('authorize');
36
		if(isset($check) and !empty($check) and $check['authority']='success')
37
		{
38
			redirect(base_url().'home');
39
		}
40
		else
41
		{
42
			$this->login();
43
		}	
44
 
45
 
46
	}
47
	function login()
48
	{
49
		//standard array
50
		$data = array();
51
		 if (isset($_SERVER['HTTP_REFERER'])) {
52
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
53
   				$redirect = $_SERVER['HTTP_REFERER'];
54
   				$location = $this->session->userdata('location');
55
   				if(isset($location) && $location == 'shipping'){
56
   					$data['location'] = 'shipping';
57
   					$location = base_url().$location;
58
   					$this->session->set_userdata('location',$location);
11520 lgm 59
   				}elseif(isset($location) && ($location == 'my-recharges' || $location == 'my-wallet')){
60
   					$location = base_url().$location;
61
   					$this->session->set_userdata('location',$location);
10582 lgm 62
   				}else{
63
   					$this->session->set_userdata('location',$redirect);	
64
   				}
65
 
66
			}
67
		}
68
		$authorized = $this->session->userdata('authorized');
69
		if(isset($authorized) && !empty($authorized) && $authorized['isLoggedIn'] == 1){
70
			redirect(base_url().'home');
71
		}
72
		//get cache 
73
		$authorized = $this->session->userdata('authorized');
74
		if(isset($_POST) && !empty($_POST)){
75
			if(isset($authorized) && !empty($authorized)){
76
				$_POST['userId'] = $authorized['Id'];
77
				$_POST['cartId'] = $authorized['cartId'];
78
				if($authorized['isLoggedIn'] == 1){
79
					$_POST['isLoggedIn'] = 'true';
80
				}
81
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
82
				$_POST['isLoggedIn'] = 'false';
83
				}
84
			}
11049 lgm 85
			//end of get cache
11171 lgm 86
			$configdata =array();
87
			$configdata = $this->config->item('oauth_login');
88
			unset($configdata['response'][0]);
89
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
15750 anikendra 90
			//error_log(print_r($data['response']['response'],1));
11049 lgm 91
			//set cache to output or renew cache
92
			if(isset($data['response']['response']['login']['authorized']))
10582 lgm 93
			{
11049 lgm 94
				$this->session->set_userdata('authorized',$data['response']['response']['login']['authorized']);
95
				//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
96
				$location = $this->session->userdata('location');
97
				if(isset($location) && !empty($location)){
98
					$this->session->unset_userdata('location');
99
					redirect($location);
10582 lgm 100
				}
11049 lgm 101
				else{
102
					redirect(base_url().$data['response']['response']['login']['redirect']);	
103
				}
104
 
105
 
10582 lgm 106
			}
11049 lgm 107
			else
108
			{
109
				$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
110
				$data['title'] = 'Saholic';
111
				$data['stylesheet'] = 'auth.css';
112
				$this->layout->view(strtolower(__CLASS__).'/oauth_view',$data);
10582 lgm 113
			}
114
		}
11049 lgm 115
		else{
11171 lgm 116
			$configdata =array();
117
			$configdata = $this->config->item('oauth_login');
118
			unset($configdata['response'][1]);
119
			$cachemodule = array('header','footer','response');
120
			$configdata = getCache($configdata,$cachemodule);
11049 lgm 121
			$data = array();
11171 lgm 122
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
10582 lgm 123
			$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
11012 lgm 124
			$data['title'] = 'Saholic';
10582 lgm 125
			$data['stylesheet'] = 'auth.css';
11171 lgm 126
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
127
			{
128
				foreach($cachemodule as $cm)
129
				{
130
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
131
					{
132
						$data['response'][$cm]=$configdata[$cm];
133
					}
134
				}
135
			}
136
			setCache($configdata['module'],$cachemodule,$data['response']);
11049 lgm 137
			$this->layout->view(strtolower(__CLASS__).'/login',$data);
10582 lgm 138
		}
139
	}
140
	function signup()
141
	{
142
		//standard array
143
		$authorized = $this->session->userdata('authorized');
144
		if(isset($authorized) && !empty($authorized) && $authorized['isLoggedIn'] == 1){
145
			redirect(base_url().'home');
146
		}
147
		$data = array();
148
		if (isset($_SERVER['HTTP_REFERER'])) {
149
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
150
   				$redirect = $_SERVER['HTTP_REFERER'];
151
   				$location = $this->session->userdata('location');
152
   				if(isset($location) && $location == 'shipping'){
153
   					$data['location'] = 'shipping';
154
   					$this->session->set_userdata('location',$location);
11520 lgm 155
   				}elseif(isset($location) && ($location == 'my-recharges' || $location == 'my-wallet')){
156
   					$location = base_url().$location;
157
   					$this->session->set_userdata('location',$location);
10582 lgm 158
   				}else{
159
   					$this->session->set_userdata('location',$redirect);	
160
   				}
161
			}
162
		}
163
		//get cache 
164
		$authorized = $this->session->userdata('authorized');
165
		if(isset($_POST) && !empty($_POST)){
166
			if(isset($authorized) && !empty($authorized)){
167
				$_POST['userId'] = $authorized['Id'];
168
				$_POST['Id'] = $authorized['cartId'];
169
				if($authorized['isLoggedIn'] == 1){
170
					$_POST['isLoggedIn'] = 'true';
171
				}
172
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
173
					$_POST['isLoggedIn'] = 'false';
174
				}
175
			}
11049 lgm 176
 
11171 lgm 177
			$configdata =array();
178
			$configdata = $this->config->item('oauth_signup');
179
			unset($configdata['response'][0]);
180
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
15750 anikendra 181
			//error_log(print_r($data['response']['response'],1));
11049 lgm 182
			//set cache to output or renew cache
183
			if(isset($data['response']['response']['signup']['authorized']))
10582 lgm 184
			{
11049 lgm 185
				$this->session->set_userdata('authorized',$data['response']['response']['signup']['authorized']);
186
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['signup']['msg']));
187
				$location = $this->session->userdata('location');
188
				if(isset($location) && !empty($location)){
189
					$this->session->unset_userdata('location');
190
					redirect($location);
10582 lgm 191
				}
11049 lgm 192
				redirect(base_url().$data['response']['response']['signup']['redirect']);
10582 lgm 193
			}
11049 lgm 194
			else
195
			{
196
				$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
197
				$data['title'] = 'Saholic';
198
				$data['stylesheet'] = 'auth.css';
199
				$this->layout->view(strtolower(__CLASS__).'/oauth_view',$data);
10582 lgm 200
			}
11049 lgm 201
		}else{
11171 lgm 202
			$configdata =array();
203
			$configdata = $this->config->item('oauth_signup');
204
			unset($configdata['response'][1]);
205
			$cachemodule = array('header','footer','response');
206
			$configdata = getCache($configdata,$cachemodule);
11049 lgm 207
			$data = array();
11171 lgm 208
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
10582 lgm 209
			$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
11012 lgm 210
			$data['title'] = 'Saholic';
10582 lgm 211
			$data['stylesheet'] = 'auth.css';
11171 lgm 212
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
213
			{
214
				foreach($cachemodule as $cm)
215
				{
216
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
217
					{
218
						$data['response'][$cm]=$configdata[$cm];
219
					}
220
				}
221
			}
222
			setCache($configdata['module'],$cachemodule,$data['response']);
11049 lgm 223
			$this->layout->view(strtolower(__CLASS__).'/signup',$data);
10582 lgm 224
		}
225
	}
226
	function logout()
227
	{
228
 
229
		$authorized = $this->session->userdata('authorized');
230
		if(isset($authorized) and !empty($authorized))
231
		{
232
			$this->session->unset_userdata('authorized');
233
			$this->session->unset_userdata('addressId');
234
			$this->session->unset_userdata('hotspotId');
235
			$this->session->unset_userdata('cod');
11412 lgm 236
			$this->session->unset_userdata('userId');
237
			$this->session->unset_userdata('captcha');
10582 lgm 238
			redirect(base_url().'home');
239
 
240
		}
241
	}
11677 lgm 242
 
243
	function changePassword()
244
  {
245
    //standard array
246
    $data = array();
247
    $authorized = $this->session->userdata('authorized');
248
    // if(isset($authorized) && !empty($authorized) && $authorized['isLoggedIn'] == 1){
249
      // redirect(base_url().'home');
250
    // }
251
    //get cache 
252
    $authorized = $this->session->userdata('authorized');
253
    if(isset($_POST) && !empty($_POST)){
254
      // print_r($_POST);
255
      // die();
256
    if(isset($authorized) && !empty($authorized)){
257
      $_POST['userId'] = $authorized['Id'];
258
      $_POST['cartId'] = $authorized['cartId'];
259
      if($authorized['isLoggedIn'] == 1){
260
        $_POST['isLoggedIn'] = 'true';
261
      }
262
      elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
263
      $_POST['isLoggedIn'] = 'false';
264
      }
265
    }
266
      //end of get cache
267
      $configdata =array();
268
      $configdata = $this->config->item('change_password');
269
      unset($configdata['response'][0]);
270
      $data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
271
      //set cache to output or renew cache
272
      if(isset($data['response']['response']['changePassword']))
273
      {
274
        $this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
275
        $data['title'] = 'Saholic';
276
        $data['stylesheet'] = 'auth.css';
277
        $this->layout->view(strtolower(__CLASS__).'/oauth_view',$data);
278
 
279
      }
280
      else
281
      {
282
        $this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
283
        $data['title'] = 'Saholic';
284
        $data['stylesheet'] = 'auth.css';
285
        $this->layout->view(strtolower(__CLASS__).'/oauth_view',$data);
286
      }
287
    }
288
    else{
289
      // echo 'inside else';
290
      // die();
291
      $configdata =array();
292
      $configdata = $this->config->item('change_password');
293
      unset($configdata['response'][1]);
294
      $cachemodule = array('header','footer','response');
295
      $configdata = getCache($configdata,$cachemodule);
296
      $data = array();
297
      $data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
298
      $this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
299
      $data['title'] = 'Saholic';
300
      $data['stylesheet'] = 'auth.css';
301
      if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
302
      {
303
        foreach($cachemodule as $cm)
304
        {
305
          if(isset($configdata[$cm]) and !empty($configdata[$cm]))
306
          {
307
            $data['response'][$cm]=$configdata[$cm];
308
          }
309
        }
310
      }
311
      setCache($configdata['module'],$cachemodule,$data['response']);
312
      $this->layout->view(strtolower(__CLASS__).'/changePassword',$data);
313
    }
314
  }
315
 
10582 lgm 316
	function forgotPassword($email)
317
	{
318
 
319
		$authorized = $this->session->userdata('authorized');
320
		if(!isset($authorized['isLoggedIn']) || ($authorized['isLoggedIn'] != 1))
321
		{
322
			if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)){
323
       			$configUrl = $this->config->item('forgotpassword');
324
		      	$configUrl = $configUrl['url'];
325
		      	$url = $this->config->item('curl_base_url').$configUrl;
326
		      	$params['emailId'] = $email;
327
		      	$this->mcurl->add_call('forgotPassword','post',$url,$params);
328
		      	$response = $this->mcurl->execute($url);
329
		      	$data['response'] = $response['forgotPassword']['response'];
330
      			print_r($data['response']);
331
       		}
332
		}
333
	}
334
 
335
	//social login process
336
	public function session($provider)
11631 lgm 337
	{
10582 lgm 338
  //   	if (isset($_SERVER['HTTP_REFERER'])) {
339
		// 	if(strpos($_SERVER['HTTP_REFERER'],'session') == false) {
340
  //  				$location = $_SERVER['HTTP_REFERER'];
341
  //  				$this->session->set_userdata('location',$location);
342
		// 	}
343
		// }
344
    	$type = $provider;
345
        $this->load->helper('url_helper');
346
        $social =$this->config->item('oauth_social');
347
 
348
        $this->load->spark('oauth2/0.4.0');
349
 
350
        $provider = $this->oauth2->provider($provider, array(
351
            'id' => $social[$provider]['id'],
352
            'secret' => $social[$provider]['secretkey']
353
 
354
        ));
355
 
356
 
357
        if ( ! $this->input->get('code'))
358
        {
359
        	if($this->input->get('error')) {
360
        		redirect(base_url());
361
        	}else{
362
        		redirect($provider->authorize());
363
        	}
364
            // By sending no options it'll come back here
365
        }
366
        else
367
        {
368
            try
369
            {
370
            	//manage login operation here and redirect to perspective link
371
                $token = $provider->access($_GET['code']);
372
 
373
                $user = $provider->get_user_info($token);
374
                if(strcasecmp('facebook', $type) == 0){
375
                	$_POST['isFacebookUser'] = 'true';
376
                	$_POST['accessToken'] = $user['access_token'];
377
                	$_POST['facebookId'] = $user['uid'];
378
                	$_POST['email'] = $user['email'];
11631 lgm 379
                	if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$_POST['email'])) {
380
  						$authorized = $this->session->userdata('authorized');
381
						if(isset($_POST) && !empty($_POST)){
382
							if(isset($authorized) && !empty($authorized)){
383
								$_POST['userId'] = $authorized['Id'];
384
								$_POST['Id'] = $authorized['cartId'];
385
								if($authorized['isLoggedIn'] == 1){
386
									$_POST['isLoggedIn'] = 'true';
387
								}
388
								elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
389
									$_POST['isLoggedIn'] = 'false';
390
								}
10582 lgm 391
							}
11631 lgm 392
						}
393
		                $data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$this->config->item('oauth_login'));
394
		                if(isset($data['response']['response']['login']['authorized']))
395
						{
396
							$this->session->set_userdata('authorized',$data['response']['response']['login']['authorized']);
397
							$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
398
							$location = $this->session->userdata('location');
399
							if(isset($location) && !empty($location)){
400
								$this->session->unset_userdata('location');
401
								redirect($location);
10582 lgm 402
							}
11631 lgm 403
							else{
404
								redirect(base_url().$data['response']['response']['login']['redirect']);	
405
							}
10582 lgm 406
						}
11631 lgm 407
						else
408
						{
409
							$inputfile = base_url().'assets/css/auth.less';
410
							$outputfile = base_url().'assets/css/auth.less';
411
							$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
412
							$data['stylesheet'] = 'auth.css';
413
							$this->layout->view(strtolower(__CLASS__).'/oauth_view',$data);
414
						}
415
					}else{
416
						$this->session->set_flashdata(array('msg'=>'Some problem occured.Please try again!'));
417
						redirect(base_url().'login');
10582 lgm 418
					}
419
				}
420
                // Here you should use this information to A) look for a user B) help a new user sign up with existing data.
421
                // If you store it all in a cookie and redirect to a registration page this is crazy-simple.
422
                //echo "<pre>Tokens: ";
423
                //var_dump($token);
424
 
425
                //echo "\n\nUser Info: ";
426
                //var_dump($user);
427
            }
428
 
429
            catch (OAuth2_Exception $e)
430
            {
431
                show_error('That didnt work: '.$e);
432
            }
433
 
434
        }
435
    }
436
 
14868 anikendra 437
    public function autologin() {
438
        $getdata = $this->input->get();
439
        //error_log(print_r($getdata,true));
15348 anikendra 440
        // $configdata = $this->config->item('gosf');
441
        // $this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');        
14868 anikendra 442
        if(isset($getdata['data']) && !empty($getdata['data'])){
443
            $data = $getdata['data'];
444
        } else{
445
            // $this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));
446
            redirect(base_url().'home');
447
        }
448
        $userData = unserialize(base64_decode($data));
449
        if(isset($getdata['next']) && !empty($getdata['next'])){
450
            $userData['next'] = $getdata['next'];
451
        }
452
        $userData['next'] = str_replace('&next=','',$userData['next']);
453
        $authorized = $this->session->userdata('authorized');
454
        //check if user is already logged in
15348 anikendra 455
        if(isset($authorized) && !empty($authorized) && $authorized['isLoggedIn'] == 1){
456
            // $this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
457
            redirect(base_url().$userData['next']);
458
        }
459
        if(isset($getdata['v']) && !empty($getdata['v'])){
460
        	$url = $this->config->item('profitmandi_token_validation_url').$getdata['token'];
15354 anikendra 461
    	 	error_log("token validation url ".$url);
15348 anikendra 462
    	 	$ch = curl_init();
463
			// Now set some options (most are optional)
464
			// Set URL to download
465
			curl_setopt($ch, CURLOPT_URL, $url);
466
			// User agent
467
			curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
468
			// Include header in result? (0 = yes, 1 = no)
469
			curl_setopt($ch, CURLOPT_HEADER, 0);
470
			// Should cURL return or print out the data? (true = return, false = print)
471
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
472
			// Timeout in seconds
473
			// curl_setopt($ch, CURLOPT_TIMEOUT, 10);
474
			// Download the given URL, and return output
475
			$output = curl_exec($ch);
476
			// Close the cURL resource, and free system resources
477
			curl_close($ch);
478
			$response = json_decode($output,1);
479
			error_log(print_r($response,1));
480
			if(empty($response) || !$response['validToken']){
481
				error_log("not authenticated");
482
				redirect(base_url().$userData['next']);	
483
			}
484
			if(!empty($response) && $response['validToken']){
485
				$userData['isLoggedIn'] = true;
486
		        $this->session->set_userdata('authorized',$userData);
487
		        error_log("authenticated user ".print_r($userData,1));
488
		        redirect(base_url().$userData['next']);
489
			}
490
        }        
491
        // $userData['stylesheet'] = 'auth.css';
492
        // $userData['title'] = 'Saholic';
14868 anikendra 493
        // if(isset($userData['next']) && !empty($userData['next'])){
494
            // $next = $userData['next'];
495
            // $this->session->set_userdata('location',$next);
496
        // }
497
        if(isset($getdata['token']) && !empty($getdata['token'])){
498
            $token = $getdata['token'];
15348 anikendra 499
        } else{        
500
            redirect(base_url().$userData['next']);
14868 anikendra 501
        }
502
        $hash = md5("21dtr022015|".$userData['Id']);
503
        //error_log(print_r($hash,true));
504
        if($hash != $token){
505
            // $this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
506
            redirect(base_url().$userData['next']);
15348 anikendra 507
        }
14868 anikendra 508
        $userData['isLoggedIn'] = true;
509
        $this->session->set_userdata('authorized',$userData);
15348 anikendra 510
        redirect(base_url().$userData['next']);
14868 anikendra 511
        // error_log("cookie ".print_r($_COOKIE,true));
15348 anikendra 512
        // $location = $this->session->userdata('location');
513
        // if(isset($location) && !empty($location)){
514
            // $this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
515
        // } else {
516
            // $this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));
517
        // }
14868 anikendra 518
    }
519
 
520
/*
14165 anikendra 521
    public function autologin() {    
14012 anikendra 522
    	$getdata = $this->input->get();
15750 anikendra 523
        //error_log(print_r($getdata,true));
14165 anikendra 524
    	$configdata = $this->config->item('gosf');
525
		$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
14442 anikendra 526
		if(isset($getdata['data']) && !empty($getdata['data'])){
14012 anikendra 527
    		$data = $getdata['data'];
528
    	}else{
15750 anikendra 529
		//error_log("data not set");
14442 anikendra 530
    		$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));
14456 anikendra 531
    	}    	
532
		$userData = unserialize(base64_decode($data));
15750 anikendra 533
                //error_log(print_r($userData,true));
14456 anikendra 534
		if(isset($getdata['next']) && !empty($getdata['next'])){
15750 anikendra 535
                //error_log("inside condition 1", 0);
536
                //error_log(print_r($getdata['next'],true));
14456 anikendra 537
    		$userData['next'] = $getdata['next'];
14012 anikendra 538
    	}
14457 anikendra 539
    	$userData['next'] = str_replace('&next=','',$userData['next']);
14442 anikendra 540
	 	$userData['stylesheet'] = 'auth.css';
541
    	$userData['title'] = 'Saholic';
15750 anikendra 542
        //error_log(print_r($userData,true));
14442 anikendra 543
    	if(isset($userData['next']) && !empty($userData['next'])){
15750 anikendra 544
                //error_log("inside condition 2", 0);
14442 anikendra 545
    		$next = $userData['next'];
546
    		$this->session->set_userdata('location',$next);
547
    	}    	
14012 anikendra 548
    	if(isset($getdata['token']) && !empty($getdata['token'])){
549
    		$token = $getdata['token'];
15750 anikendra 550
                //error_log(print_r($token,true));
14012 anikendra 551
    	}else{
14442 anikendra 552
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
553
    	}    	    	
14165 anikendra 554
    	$hash = md5("21dtr022015|".$userData['Id']);    	
15750 anikendra 555
        //error_log(print_r($hash,true));
14012 anikendra 556
    	if($hash != $token){
15750 anikendra 557
 
14442 anikendra 558
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
14012 anikendra 559
    	}
15750 anikendra 560
                  error_log("inside condition 5", 0);
14165 anikendra 561
		$userData['isLoggedIn'] = true;
14012 anikendra 562
		$this->session->set_userdata('authorized',$userData);
15750 anikendra 563
	error_log("cookie ".print_r($_COOKIE,true));
14012 anikendra 564
		$location = $this->session->userdata('location');
565
		if(isset($location) && !empty($location)){
15750 anikendra 566
                        error_log("inside condition 6", 0);
567
//			$this->session->unset_userdata('location');
14442 anikendra 568
			$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
14012 anikendra 569
		}
570
		else{
15750 anikendra 571
                       error_log("inside condition 7", 0);
14442 anikendra 572
			$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));			
14012 anikendra 573
		}
574
    }
14868 anikendra 575
    */
10582 lgm 576
}
577
 
578
/***** FOR LOGIN AUTHENTICATION *****
579
*    AUTHORIZE ARRAY + AUTHORIZE[AUTHORITY]=SUCCESS
580
*	 FOR SIGN UP - 
581
*
582
*
583
 
584
/* End of file welcome.php */
15750 anikendra 585
/* Location: ./application/controllers/welcome.php */