/
UserController.php
170 lines (153 loc) · 4.13 KB
/
UserController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* Knowfox - Personal Knowledge Management
* Copyright (C) 2017 Olav Schettler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Knowfox\Http\Controllers;
use Illuminate\Http\Request;
use Knowfox\User;
use Illuminate\Support\Facades\Auth;
use Knowfox\Models\EmailLogin;
class UserController extends Controller
{
public function __construct(Request $request)
{
$this->setAuthMiddleware($request);
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
/**
* @todo Adapt from Chosenreich
* @param $what
* @param $email
* @return \Illuminate\Http\RedirectResponse
*/
public function cancel($what, $email)
{
$user = User::where('email', $email)->firstOrFail();
if ($what == 'all') {
$user->email_upcoming = 0;
$user->email_comment = 0;
$user->email_story = 0;
$user->email_recipient = 0;
$user->email_newsletter = 0;
$user->email_promo = 0;
$user->save();
return redirect()->back()
->with('message', "Du erhälst keine E-Mails mehr von uns");
} else {
if (in_array($what, [
'upcoming',
'comment',
'story',
'recipient',
'newsletter',
'promo'
])) {
$field = 'email_' . $what;
$user->{$field} = 0;
$user->save();
return redirect()->back()
->with('message', "Du erhälst keine E-Mails zu '
. ucfirst($what) . ' mehr von uns");
} else {
return redirect()->back()
->with('message', 'Zu diesem Thema versenden wir keine E-Mails');
}
}
}
public function token()
{
$email = Auth::user()->email;
EmailLogin::where('email', $email)->delete();
$email_login = EmailLogin::createForEmail($email);
return response()->json(['token' => $email_login->token]);
}
public function passport()
{
return view('auth.passport', [
'page_title' => 'Passport',
'sub_title' => 'Manage your API tokens',
]);
}
}