<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Facebook extends Public_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->library('facebook_api');
	}
	function request_auth()
	{
		if(is_login())
        {
            alert("로그인중입니다.");
            redirect("");    
            exit;
        }

		$this->facebook_api->request_auth();
	}
	function redirect_url()
	{
        $auth_result =$this->facebook_api->login_callback();
        
        $access_token=$auth_result->access_token;
        $info=$this->facebook_api->get_user_profile($access_token);
        // var_dump($auth_result);
		
		if($info == null)
		{
			 echo "<script>window.close();</script>";
			 return;
		}
		if(isset($info->name)) //프로필 받아오기 성공이라면
		{
		
			$name = $info->name;
			$sns_id = $info->id;
			$email = null;
			$gender =$info->gender;
			$sns_type = "facebook";
			$refresh_token= isset($auth_result->refresh_token) ? $auth_result->refresh_token: null;
			$this->load->model("sns_info_model");
			$this->load->model("base/users_model");
			$sns_info =$this->sns_info_model->_get(array("sns_id"=>$sns_id,"sns_type"=>$sns_type));
		
			if($sns_info === null) //해당 프로필이 로컬 db에 존재하지 않는다면
			{
			
			
				 $this->db->set("name",$name);
				//  $this->db->set("profilePhoto",$info->profile_image);
				 $this->db->set("userName",$email);
				 $this->db->set("sns_type",$sns_type);
				 $this->db->set("email",$email);<commit_msg>페이스북으로 회원가입할떄 이메일 저장버그 수정<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Facebook extends Public_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->library('facebook_api');
	}
	function request_auth()
	{
		if(is_login())
        {
            alert("로그인중입니다.");
            redirect("");    
            exit;
        }

		$this->facebook_api->request_auth();
	}
	function redirect_url()
	{
        $auth_result =$this->facebook_api->login_callback();
        
        $access_token=$auth_result->access_token;
        $info=$this->facebook_api->get_user_profile($access_token);
        // var_dump($auth_result);
		
		if($info == null)
		{
			 echo "<script>window.close();</script>";
			 return;
		}
		if(isset($info->name)) //프로필 받아오기 성공이라면
		{
		
			$name = $info->name;
			$sns_id = $info->id;
			$email = $info->email;
			$gender =$info->gender;
			$sns_type = "facebook";
			$refresh_token= isset($auth_result->refresh_token) ? $auth_result->refresh_token: null;
			$this->load->model("sns_info_model");
			$this->load->model("base/users_model");
			$sns_info =$this->sns_info_model->_get(array("sns_id"=>$sns_id,"sns_type"=>$sns_type));
		
			if($sns_info === null) //해당 프로필이 로컬 db에 존재하지 않는다면
			{
			
			
				 $this->db->set("name",$name);
				//  $this->db->set("profilePhoto",$info->profile_image);
				 $this->db->set("userName",$email);
				 $this->db->set("sns_type",$sns_type);
				 $this->db->set("email",$email);
{'fraction_non_alphanumeric': 0.19179452968645763, 'fraction_numerical': 0.0, 'mean_word_length': 3.3213256484149856, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1208686', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1178, 'n_words': 145}