/** * checks code again, and updates user password * * @return redirect * @author Me */ public function postResetPassword() { if (!Request::has('email') or !Request::has('code') or !Request::has('password')) { return redirect('/')->with('error', 'Geçersiz istek.')->withInput(); } $user = User::where('email', Request::get('email'))->where('password_reset_token', Request::get('code'))->first(); if (empty($user)) { return redirect('/')->with('error', 'geçersiz istek')->withInput(); } $user->password_reset_token = null; $user->password_token_expires_at = null; $user->password = bcrypt(Request::get('password')); try { $user->save(); #TODO: maybe send an email to confirm password change. } catch (Exception $e) { Log::error('AuthController/postResetPassword', (array) $e); return redirect('/')->with('error', 'Teknik bir hatadan dolayı şu anda şifre güncelleme işlemini yapamadım.')->withInput(); } return redirect('/login')->with('success', 'Şifreniz başarılı bir şekilde güncellendi. Yeni şifreniz ile giriş yapabilirsiniz.'); }
/** * get supporter list for an issue * * @return mixed * @author gcg */ public function getSupporters($id = null, $start = 0, $take = 20) { $issue = Issue::find($id); if ($issue === null) { if ($this->isApi) { return response()->api(404, 'Issue not found', []); } return redirect('/issues')->with('error', 'Fikir bulunamadı.'); } $supporter_ids = []; $supporter_ids = DB::table('issue_supporters')->where('issue_id', $issue->id)->orderBy('created_at', 'desc')->skip($start)->take($take)->lists('user_id'); $users = []; if (!empty($supporter_ids)) { $users = User::whereIn('id', $supporter_ids)->get(); if (!empty($users)) { $users = $users->toArray(); } } if ($this->isApi) { return response()->api(200, 'List of issue supporters: ' . $id, $users); } session(['last_page' => Request::path()]); return response()->app(200, 'issues.supporters', ['users' => $users]); }
/** * deletes a member from the database * * @return redirect * @author gcg */ public function getDeleteMember($id = null) { $member = User::find($id); if (empty($member)) { return redirect('/admin/members')->with('error', 'Aradığınız kullanıcı bulunamıyor. '); } $tmp = ['created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'source_id' => Auth::user()->id, 'previous_level' => $member->level, 'current_level' => 0, 'user_id' => $member->id]; try { $member->delete(); DB::table('user_updates')->insert($tmp); } catch (Exception $e) { Log::error('AdminController/getDeleteMember', (array) $e); return redirect('/admin/members')->with('error', 'Üye silinirken bir hata oluştu.'); } return redirect('/admin/members')->with('success', 'Üye silindi.'); }
/** * update a users profile * * @return json * @author gcg */ public function postUpdate() { $data = Request::all(); if ($this->isApi) { $user_id = Authorizer::getResourceOwnerId(); } else { $user_id = Auth::user()->id; } $user = User::find($user_id); if (empty($user)) { if ($this->isApi) { return response()->api(401, 'User issue', []); } return redirect('/')->with('error', 'Kullanıcı bulanamdı.'); } if (isset($data['email']) and filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { $user->email = $data['email']; $user->is_verified = 0; } #lets figure out the location. $location_parts = explode(",", $data['location']); $hood = false; if (count($location_parts) === 3) { $hood = Hood::fromLocation($data['location']); } if (isset($hood) and isset($hood->id)) { $user->hood_id = $hood->id; } if (isset($data['username']) and !empty($data['username'])) { $data['username'] = Str::slug($data['username']); $check_slug = (int) DB::table('users')->where('username', $data['username'])->where('id', '<>', $user_id)->count(); if ($check_slug === 0) { $user->username = $data['username']; } } if (isset($data['first_name']) and !empty($data['first_name'])) { $user->first_name = $data['first_name']; } if (isset($data['last_name']) and !empty($data['last_name'])) { $user->last_name = $data['last_name']; } if (isset($data['location']) and !empty($data['location'])) { $user->location = $data['location']; } if (!empty($data['image']) and is_array($data['image'])) { try { $name = str_replace('.', '', microtime(true)); Storage::put('users/' . $name, base64_decode($data['image'])); $user->picture = $name; } catch (Exception $e) { Log::error('MembersController/postUpdate/SavingTheImage', (array) $e); } } try { $user->save(); } catch (Exception $e) { Log::error('MembersController/postUpdate', (array) $e); if ($this->isApi) { return response()->api(500, 'Tech problem', []); } return redirect('/members/edit-profile')->with('error', 'Profilinizi güncellerken bir hata meydana geldi.'); } if ($this->isApi) { } return redirect('/members/my-profile')->with('success', 'Profiliniz güncellendi.'); }