Subversion Repositories SmartDukaan

Rev

Rev 15354 | Rev 16276 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15354 Rev 15750
Line 1... Line 1...
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
 
-
 
3
class Auth extends MY_Controller {
2
class Auth extends MY_Controller {
4
 
-
 
5
public $layoutName ='';
3
public $layoutName ='';
6
	
-
 
7
	function __construct() {
4
	function __construct() {
8
 
5
 
9
		// Call the CI_controller constructor
6
		// Call the CI_controller constructor
10
		parent::__construct();
7
		parent::__construct();
11
		// $admin = $this->session->userdata('admin');
8
		// $admin = $this->session->userdata('admin');
Line 88... Line 85...
88
			//end of get cache
85
			//end of get cache
89
			$configdata =array();
86
			$configdata =array();
90
			$configdata = $this->config->item('oauth_login');
87
			$configdata = $this->config->item('oauth_login');
91
			unset($configdata['response'][0]);
88
			unset($configdata['response'][0]);
92
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
89
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
93
			error_log(print_r($data['response']['response'],1));
90
			//error_log(print_r($data['response']['response'],1));
94
			//set cache to output or renew cache
91
			//set cache to output or renew cache
95
			if(isset($data['response']['response']['login']['authorized']))
92
			if(isset($data['response']['response']['login']['authorized']))
96
			{
93
			{
97
				$this->session->set_userdata('authorized',$data['response']['response']['login']['authorized']);
94
				$this->session->set_userdata('authorized',$data['response']['response']['login']['authorized']);
98
				//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
95
				//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
Line 179... Line 176...
179
		
176
		
180
			$configdata =array();
177
			$configdata =array();
181
			$configdata = $this->config->item('oauth_signup');
178
			$configdata = $this->config->item('oauth_signup');
182
			unset($configdata['response'][0]);
179
			unset($configdata['response'][0]);
183
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
180
			$data['response']=$this->oauth_model->getLogin($this->input->get(),$this->input->post(),$configdata);
184
			error_log(print_r($data['response']['response'],1));
181
			//error_log(print_r($data['response']['response'],1));
185
			//set cache to output or renew cache
182
			//set cache to output or renew cache
186
			if(isset($data['response']['response']['signup']['authorized']))
183
			if(isset($data['response']['response']['signup']['authorized']))
187
			{
184
			{
188
				$this->session->set_userdata('authorized',$data['response']['response']['signup']['authorized']);
185
				$this->session->set_userdata('authorized',$data['response']['response']['signup']['authorized']);
189
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['signup']['msg']));
186
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['signup']['msg']));
Line 521... Line 518...
521
    }
518
    }
522
 
519
 
523
/*
520
/*
524
    public function autologin() {    
521
    public function autologin() {    
525
    	$getdata = $this->input->get();
522
    	$getdata = $this->input->get();
-
 
523
        //error_log(print_r($getdata,true));
526
    	$configdata = $this->config->item('gosf');
524
    	$configdata = $this->config->item('gosf');
527
		$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
525
		$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
528
		if(isset($getdata['data']) && !empty($getdata['data'])){
526
		if(isset($getdata['data']) && !empty($getdata['data'])){
529
    		$data = $getdata['data'];
527
    		$data = $getdata['data'];
530
    	}else{
528
    	}else{
-
 
529
		//error_log("data not set");
531
    		$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));
530
    		$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));
532
    	}    	
531
    	}    	
533
		$userData = unserialize(base64_decode($data));
532
		$userData = unserialize(base64_decode($data));
-
 
533
                //error_log(print_r($userData,true));
534
		if(isset($getdata['next']) && !empty($getdata['next'])){
534
		if(isset($getdata['next']) && !empty($getdata['next'])){
-
 
535
                //error_log("inside condition 1", 0);
-
 
536
                //error_log(print_r($getdata['next'],true));
535
    		$userData['next'] = $getdata['next'];
537
    		$userData['next'] = $getdata['next'];
536
    	}
538
    	}
537
    	$userData['next'] = str_replace('&next=','',$userData['next']);
539
    	$userData['next'] = str_replace('&next=','',$userData['next']);
538
	 	$userData['stylesheet'] = 'auth.css';
540
	 	$userData['stylesheet'] = 'auth.css';
539
    	$userData['title'] = 'Saholic';
541
    	$userData['title'] = 'Saholic';
-
 
542
        //error_log(print_r($userData,true));
540
    	if(isset($userData['next']) && !empty($userData['next'])){
543
    	if(isset($userData['next']) && !empty($userData['next'])){
-
 
544
                //error_log("inside condition 2", 0);
541
    		$next = $userData['next'];
545
    		$next = $userData['next'];
542
    		$this->session->set_userdata('location',$next);
546
    		$this->session->set_userdata('location',$next);
543
    	}    	
547
    	}    	
544
    	if(isset($getdata['token']) && !empty($getdata['token'])){
548
    	if(isset($getdata['token']) && !empty($getdata['token'])){
545
    		$token = $getdata['token'];
549
    		$token = $getdata['token'];
-
 
550
                //error_log(print_r($token,true));
546
    	}else{
551
    	}else{
547
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
552
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
548
    	}    	    	
553
    	}    	    	
549
    	$hash = md5("21dtr022015|".$userData['Id']);    	
554
    	$hash = md5("21dtr022015|".$userData['Id']);    	
-
 
555
        //error_log(print_r($hash,true));
550
    	if($hash != $token){
556
    	if($hash != $token){
-
 
557
                 
551
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
558
    		$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
552
    	}
559
    	}
553
    	if (isset($_SERVER['HTTP_REFERER'])) {
-
 
554
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
-
 
555
   				$redirect = $_SERVER['HTTP_REFERER'];
-
 
556
   				$location = $this->session->userdata('location');
560
                  error_log("inside condition 5", 0);
557
   				if(isset($location) && $location == 'shipping'){
-
 
558
   					$data['location'] = 'shipping';
-
 
559
   					$location = base_url().$location;
-
 
560
   					$this->session->set_userdata('location',$location);
-
 
561
   				}elseif(isset($location) && ($location == 'my-recharges' || $location == 'my-wallet')){
-
 
562
   					$location = base_url().$location;
-
 
563
   					$this->session->set_userdata('location',$location);
-
 
564
   				}else{
-
 
565
   					$this->session->set_userdata('location',$redirect);	
-
 
566
   				}   				
-
 
567
			}
-
 
568
		}
-
 
569
		$userData['isLoggedIn'] = true;
561
		$userData['isLoggedIn'] = true;
570
		$this->session->set_userdata('authorized',$userData);
562
		$this->session->set_userdata('authorized',$userData);
-
 
563
	error_log("cookie ".print_r($_COOKIE,true));
571
		$location = $this->session->userdata('location');
564
		$location = $this->session->userdata('location');
572
		if(isset($location) && !empty($location)){
565
		if(isset($location) && !empty($location)){
-
 
566
                        error_log("inside condition 6", 0);
573
			$this->session->unset_userdata('location');
567
//			$this->session->unset_userdata('location');
574
			$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
568
			$this->layout->view(strtolower(__CLASS__).'/autologin',$userData);
575
		}
569
		}
576
		else{
570
		else{
-
 
571
                       error_log("inside condition 7", 0);
577
			$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));			
572
			$this->layout->view(strtolower(__CLASS__).'/autologin',array('next'=>base_url()));			
578
		}
573
		}
579
    }
574
    }
580
    */
575
    */
581
}
576
}
Line 585... Line 580...
585
*	 FOR SIGN UP - 
580
*	 FOR SIGN UP - 
586
*
581
*
587
*
582
*
588
 
583
 
589
/* End of file welcome.php */
584
/* End of file welcome.php */
590
/* Location: ./application/controllers/welcome.php */
-
 
591
585
/* Location: ./application/controllers/welcome.php */
-
 
586