source: app/Http/Controllers/Dashboard/SettingsController.php@ bd9e8e3

develop
Last change on this file since bd9e8e3 was bd9e8e3, checked in by Berat Kjufliju <kufliju@…>, 3 years ago

added arch_id validation

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[194a359]1<?php
2
3namespace App\Http\Controllers\Dashboard;
4
5use App\Http\Requests\Dashboard\EmailSettingsRequest;
6use App\Http\Requests\Dashboard\PasswordSettingsRequest;
7use App\Http\Requests\Dashboard\UsernameSettingsRequest;
8use App\Models\User;
9use App\Http\Controllers\Controller;
10use App\Notifications\VerifyNewEmail;
[d795fa6]11use Carbon\Carbon;
[194a359]12
13class SettingsController extends Controller
14{
15 public function settings()
16 {
17 return view("dashboard.settings.index")->with([
18 "user" => auth()->user(),
[d795fa6]19 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
[bd9e8e3]20 "active_tab" => "account"
[194a359]21 ]);
22 }
23
24 public function updateUsername(UsernameSettingsRequest $request)
25 {
[bd9e8e3]26 if ($request->validated()) {
27 $user = auth()->user();
28 $user->username = $request->username;
29 $user->save();
30
31 auth()->logout();
32 session()->flush();
33
34 return redirect()->route("auth.loginShow");
35 } else {
36 return back()->with(['active_tab' => 'security']);
37 }
38
39 dd('no');
[194a359]40 }
41
42 public function updatePassword(PasswordSettingsRequest $request)
43 {
44 $user = auth()->user();
45 $user->password = bcrypt($request->password);
46 $user->save();
47
48 auth()->logout();
49 session()->flush();
50
51 return redirect()->route("auth.loginShow");
52 }
53
54 public function updateEmail(EmailSettingsRequest $request)
55 {
56 $user = auth()->user();
57
58 $user->email = $request->email;
59 $user->is_active = false;
60 $user->security_code = $user->generateSecurityCode();
61 $user->verify_token = $user->generateVerifyToken();
62
63 $user->save();
64
65 $user->notify(new VerifyNewEmail($user));
66
67 auth()->logout();
68 session()->flush();
69
70 return redirect()->route("auth.loginShow");
71 }
72
73}
Note: See TracBrowser for help on using the repository browser.