Пример #1
0
 public function login()
 {
     try {
         $passwordMatch = false;
         $userDeviceUpdated = false;
         $access_token = '';
         $input = Request::all();
         $user = User::where('email', $input['email'])->first();
         if ($user) {
             if (crypt($input['password'], $user->password) == $user->password) {
                 $passwordMatch = true;
             }
         }
         if ($passwordMatch) {
             $userDevice = UserDevice::where('device_id', $input['device_id'])->first();
             $access_token = Uuid::uuid1()->toString();
             if ($userDevice) {
                 $userDeviceUpdated = $userDevice->update(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
             } else {
                 $userDeviceUpdated = UserDevice::create(['device_id' => $input['device_id'], 'rest_access_token' => $access_token, 'rest_access_token_expires' => Carbon::now()->addDays(360), 'rest_notification_id' => $input['notification_id'], 'os_type' => $input['os_type'], 'os_version' => $input['os_version'], 'hardware' => $input['hardware'], 'rest_app_version' => $input['app_version'], 'user_id' => $user->id]);
             }
         }
         if ($userDeviceUpdated) {
             $vendorLocationContact = VendorLocationContact::where('user_id', $user->id)->first();
             $vendorLocation = VendorLocation::where('id', $vendorLocationContact->vendor_location_id)->first();
             $vendor = Vendor::where('id', $vendorLocation->vendor_id)->first();
             return response()->json(['id' => $user->id, 'access_token' => $access_token, 'full_name' => $user->full_name, 'email' => $user->email, 'phone_number' => $user->phone_number, 'role' => $user->role->name, 'vendor_name' => $vendor->name], 200);
         } else {
             return response()->json(['action' => 'Check if the email address and password match', 'message' => 'There is an email password mismatch. Please check and try again'], 227);
         }
     } catch (\Exception $e) {
         return response()->json(['message' => 'An application error occured.', 'error' => $e->getMessage()], 500);
     }
 }
Пример #2
0
 /**
  * Updates the user password to the new value.
  *
  * @static
  * @access  public
  * @param   array   $arrData
  * @return  array
  * @since   1.0.0
  */
 public static function updatePasswordDatabase($arrData)
 {
     $user = PasswordRequest::where('request_token', '=', $arrData['token'])->first();
     $password = bcrypt($arrData['password']);
     User::where('id', '=', $user['user_id'])->update(['password' => $password, 'type' => 'new_site']);
     PasswordRequest::where('request_token', '=', $arrData['token'])->update(['status' => 'used']);
     $arrResponse['status'] = Config::get('constants.API_SUCCESS');
     $arrResponse['msg'] = 'Password set successfully.';
     return $arrResponse;
 }
Пример #3
0
 public function register()
 {
     $rules = ['email' => 'required|email', 'password' => 'required', 'city' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $string_msg = "";
         $messages = head($validator->messages());
         // echo "<pre>";
         // print_r(Input::all());exit;
         foreach (head($messages) as $key => $value) {
             $string_msg .= $value . "\n";
         }
         echo $string_msg;
     }
     $res = User::where('email', Input::get('email'))->get()->toArray();
     if (count($res) >= 1) {
         echo "This email address is already registered with WowTables.com ";
     } else {
         $google_add = Cookie::get('google_add_words');
         $users['email_address'] = Input::get('email');
         $users['password'] = Input::get('password');
         $users['city'] = Input::get('city');
         $users['full_name'] = Input::get('full_name');
         $login_type = Input::get('login_type');
         $reg_page = Input::get('reg_page');
         $usr_phone = Input::get('phone');
         $gourmetRoleId = DB::table('roles')->where('name', 'Gourmet')->pluck('id');
         $users['role_id'] = $gourmetRoleId;
         $users['google_addwords'] = isset($google_add) && $google_add == 1 ? "1" : "0";
         $users['last_login'] = '******';
         $users['facebook_id'] = 0;
         if ($users['facebook_id'] != 0) {
             $facebook_id = $users['facebook_id'];
         }
         $registerinfo = $this->customermodel->register($users);
         $last_id = $registerinfo['user_id'];
         // update membership_number
         // update email_whitelist
         if ($registerinfo['state'] === 'success') {
             if (isset($login_type) && $login_type != "") {
                 $set_login_type = $login_type;
             } else {
                 $set_login_type = "Email";
             }
             if (isset($reg_page) && $reg_page != "") {
                 $set_reg_page = $reg_page;
             } else {
                 $set_reg_page = "http://www.wowtables.com/registration";
             }
             $usr_email = Input::get('email');
             if ($usr_phone != "") {
                 DB::update("update users set phone_number ='{$usr_phone}' where email = '{$usr_email}'");
             }
             $newdata = array('id' => $last_id, 'username' => substr($users['email_address'], 0, strpos($users['email_address'], "@")), 'email' => $users['email_address'], 'logged_in' => TRUE, 'city' => $users['city']);
             $newdata['add_mixpanel_event'] = 'yes';
             $newdata['login_type'] = $set_login_type;
             $newdata['Registration_Page'] = $set_reg_page;
             Session::put($newdata);
             $mailbody = "\nYou are now a WowTables VIP!\n\nThank you for joining WowTables.com!\n\nYour account details are:\nEmail:" . $users['email_address'] . "\nPassword:"******"\n\nWe add new experiences from the best restaurants in Mumbai,Pune,Delhi,Bengaluru every week. So the next time you feel like treating yourself or a loved one to something special just check out WowTables.com or call our concierge at 9619551387 to make a booking. We hope you will enjoy what we have to offer.\n\nHappy Dining,\nThe WowTables Team";
             $city_name = Location::where(['Type' => 'City', 'id' => $users['city']])->pluck('name');
             if (empty($city_name)) {
                 $city_name = 'mumbai';
             }
             /*Mail::raw($mailbody, function($message) use ($users)
             					{
             					    $message->from('*****@*****.**', 'WowTables by GourmetItUp');
             
             					    $message->to($users['email_address'])->subject('Registration with WowTables');
             					});*/
             /*$newdata = array(
             			'id'  => $last_id,
             			'username'  => substr($users['email_address'],0,strpos($users['email_address'],"@")),
             			'email'     => $users['email_address'],
             			'logged_in' => TRUE,
             			'city' => $users['city']
             	   );
             		$newdata['add_mixpanel_event'] = 'yes';
             		$newdata['login_type'] = $set_login_type;
             		$newdata['Registration_Page'] = $set_reg_page;*/
             //$this->email->send();
             //Start MailChimp
             //require_once 'MCAPI.class.php'; //specify the proper path
             /*if(!isset($_GET["utm_source"])) $_GET["utm_source"] = "";
               if(!isset($_GET["utm_medium"])) $_GET["utm_medium"] = "";
               if(!isset($_GET["utm_campaign"])) $_GET["utm_campaign"] = "";*/
             $city = ucfirst($city_name);
             $merge_vars = array('NAME' => isset($users['full_name']) ? $users['full_name'] : '', 'SIGNUPTP' => isset($facebook_id) ? 'Facebook' : 'Email', 'BDATE' => isset($users['dob']) ? $users['dob'] : '', 'GENDER' => isset($users['gender']) ? $users['gender'] : '', 'MERGE11' => 0, 'MERGE17' => 'Has WowTables account', 'PHONE' => isset($users['phone']) ? $users['phone'] : '', 'MERGE18' => isset($_GET["utm_source"]) ? $_GET["utm_source"] : '', 'MERGE19' => isset($_GET["utm_medium"]) ? $_GET["utm_medium"] : '', 'MERGE20' => isset($_GET["utm_campaign"]) ? $_GET["utm_campaign"] : '', 'GROUPINGS' => array(array('id' => 9713, 'groups' => [$city])));
             $this->mailchimp->lists->subscribe($this->listId, ["email" => $_POST['email']], $merge_vars, "html", false, true);
             //print_r($test);die;
             //echo "<pre>"; print_r($api); die;
             //$api->listSubscribe($listId, $_POST['email'], $merge_vars,"html",false,true );
             //$my_email = $users['email_address'];
             //$city = $users['city'];
             //echo "asd , ";
             //$this->mailchimp->lists->interestGroupings($this->listId,true);
             //print_r($test);die;
             //$test = $this->mailchimp->lists->updateMember($this->listId, ["email"=>$_POST['email']], $mergeVars);
             //print_r($test);die;
             //End MailChimp
             echo 1;
         } else {
             echo $registerinfo['message'];
         }
     }
 }