public function postForgotPassword() { $email = Input::get('email'); $user = User::where('email', $email)->first(); if (is_object($user) && count($user) > 0) { $password = BRMHelper::genRandomPassword(); $user->password = $password; $user->updateUniques(); //send new password to user MailHelper::forgotPasswordMessage($user->email, $password); Session::flash('notice', 'Success! New password coming your way. Please check your email.'); return View::make('public.forgot_password'); } else { Session::flash('alert', 'Sorry, <strong>' . $email . '</strong> has no associated account yet.'); return View::make('public.forgot_password'); } }
protected function migrateUsers() { DB::connection('local_new_portal')->table('users')->where('email', '<>', '*****@*****.**')->delete(); $old_table = 'member'; $new_table = 'users'; $password = $this->ask("We have to reset user passwords because the encryption algorythm has changed in our new system. Please provide new password for all users:"); $password = Hash::make($password); $new_password = function () use($password) { return $password; }; //migrate user fund to user transaction $fund = function ($old_table_row, $new_table, $old_table) { $date = date('Y-m-d h:i:s'); $transaction = array('amount' => $old_table_row->credits, 'remarks' => 'Total fund from old system', 'transaction_id' => BRMHelper::genRandomTransactionId(), 'type' => 1, 'user_id' => $old_table_row->id, 'created_at' => $date, 'updated_at' => $date); DB::connection('local_new_portal')->table('user_transactions')->insert($transaction); return $old_table_row->credits; }; $fields = array('id' => 'id', 'email' => 'email', 'password' => $new_password, 'firstname' => 'first_name', 'lastname' => 'last_name', 'customer_type' => 'type', 'fund' => $fund, 'created_at' => 'creation_date', 'updated_at' => 'creation_date', 'ip' => 'ip'); $this->migrate($old_table, $new_table, $fields); }