Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
121
application/libraries/apis/Signup.php
Normal file
121
application/libraries/apis/Signup.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Signup
|
||||
*/
|
||||
|
||||
|
||||
class Signup extends CI_Controller
|
||||
{
|
||||
|
||||
private $CI;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->CI = & get_instance();
|
||||
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
|
||||
if ( ! $this->CI->input->post_get('token')) {
|
||||
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
|
||||
}
|
||||
$token = $this->CI->input->post_get('token');
|
||||
|
||||
|
||||
$app_id = (int) trim($this->CI->input->post_get('app_id'));
|
||||
if (empty($app_id)) {
|
||||
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
|
||||
}
|
||||
|
||||
|
||||
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
|
||||
|
||||
|
||||
if ( ! function_exists('password_hash')) {
|
||||
$this->load->helper('password');
|
||||
}
|
||||
$this->CI->load->helper('email');
|
||||
|
||||
if ( ! $this->CI->input->post('user_email')) {
|
||||
$this->CI->apilib->make_error("회원 이메일이 입력되지 않았습니다");
|
||||
}
|
||||
if ( ! valid_email($this->CI->input->post('user_email')) ) {
|
||||
$this->CI->apilib->make_error("이메일이 형식에 맞지 않습니다.");
|
||||
}
|
||||
if ( ! $this->CI->input->post('user_username')) {
|
||||
$this->CI->apilib->make_error("회원 닉네임이 입력되지 않았습니다");
|
||||
}
|
||||
if ( ! $this->CI->input->post('user_password')) {
|
||||
$this->CI->apilib->make_error("비밀번호를 입력해주십시오.");
|
||||
}
|
||||
if ($this->CI->input->post('user_password') != $this->CI->input->post('user_password2')) {
|
||||
$this->CI->apilib->make_error("비밀번호가 일치하지 않습니다. 다시 입력해주세요.");
|
||||
}
|
||||
|
||||
$user_email = trim($this->CI->input->post('user_email'));
|
||||
$user_username = trim($this->CI->input->post('user_username'));
|
||||
$user_password = trim($this->CI->input->post('user_password'));
|
||||
|
||||
$userwhere = array(
|
||||
'app_id' => $app_id,
|
||||
'user_email' => $user_email,
|
||||
);
|
||||
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
|
||||
if (element('user_id', $row)) {
|
||||
$this->CI->apilib->make_error("이미 사용중인 이메일입니다. 다른 이메일을 입력해주세요.");
|
||||
}
|
||||
|
||||
$userwhere = array(
|
||||
'app_id' => $app_id,
|
||||
'user_username' => $user_username,
|
||||
);
|
||||
$row = $this->CI->User_model->get_one('', 'user_id', $userwhere);
|
||||
if (element('user_id', $row)) {
|
||||
$this->CI->apilib->make_error("이미 사용중인 닉네임입니다. 다른 닉네임을 입력해주세요.");
|
||||
}
|
||||
|
||||
$insertdata = array(
|
||||
'app_id' => $app_id,
|
||||
'user_email' => $user_email,
|
||||
'user_password' => password_hash($user_password, PASSWORD_BCRYPT),
|
||||
'user_username' => $user_username,
|
||||
'user_register_datetime' => cdate('Y-m-d H:i:s'),
|
||||
'user_token' => $token,
|
||||
);
|
||||
|
||||
$user_id = $this->CI->User_model->insert($insertdata);
|
||||
|
||||
$dwhere = array(
|
||||
'app_id' => $app_id,
|
||||
'user_id <>' => $user_id,
|
||||
'user_token' => $token,
|
||||
);
|
||||
$this->CI->User_model->delete('', $dwhere);
|
||||
|
||||
//fcm token 등록하기
|
||||
if ($this->CI->input->post('fcm_token')) {
|
||||
$this->CI->load->library('Fcm_library');
|
||||
$this->CI->fcm_library->update_token($user_id, $this->CI->input->post('fcm_token'));
|
||||
}
|
||||
|
||||
|
||||
//$this->CI->session->set_userdata('user_id', $user_id);
|
||||
|
||||
$arr = array(
|
||||
'result' => 'ok',
|
||||
'token' => $token,
|
||||
'user_id' => $user_id,
|
||||
'user_email' => $user_email,
|
||||
'user_username' => $user_username,
|
||||
'datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user