@@ -14,7 +14,7 @@ |
||
14 | 14 | public function register() |
15 | 15 | { |
16 | 16 | // Register Mailing Services |
17 | - $this->app->singleton('mailer', function ($app) { |
|
17 | + $this->app->singleton('mailer', function($app) { |
|
18 | 18 | return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer'); |
19 | 19 | }); |
20 | 20 | } |
@@ -1,24 +1,24 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Providers; |
|
3 | + namespace App\Providers; |
|
4 | 4 | |
5 | -use Illuminate\Support\ServiceProvider; |
|
5 | + use Illuminate\Support\ServiceProvider; |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Class AppServiceProvider. |
9 | 9 | */ |
10 | -class AppServiceProvider extends ServiceProvider |
|
11 | -{ |
|
12 | - /** |
|
10 | + class AppServiceProvider extends ServiceProvider |
|
11 | + { |
|
12 | + /** |
|
13 | 13 | * Register any application services. |
14 | 14 | * |
15 | 15 | * @return void |
16 | 16 | */ |
17 | - public function register() |
|
18 | - { |
|
19 | - // Register Mailing Services |
|
20 | - $this->app->singleton('mailer', function ($app) { |
|
21 | - return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer'); |
|
22 | - }); |
|
23 | - } |
|
17 | + public function register() |
|
18 | + { |
|
19 | + // Register Mailing Services |
|
20 | + $this->app->singleton('mailer', function ($app) { |
|
21 | + return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer'); |
|
22 | + }); |
|
23 | + } |
|
24 | 24 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function register() |
20 | 20 | { |
21 | - $this->app->bind('chocosession', function () { |
|
21 | + $this->app->bind('chocosession', function() { |
|
22 | 22 | return Session::getInstance(); |
23 | 23 | }); |
24 | 24 |
@@ -1,26 +1,26 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Providers; |
|
3 | + namespace App\Providers; |
|
4 | 4 | |
5 | -use App\Helpers\Session; |
|
6 | -use Illuminate\Support\ServiceProvider; |
|
5 | + use App\Helpers\Session; |
|
6 | + use Illuminate\Support\ServiceProvider; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Class SessionServiceProvider. |
10 | 10 | */ |
11 | -class SessionServiceProvider extends ServiceProvider |
|
12 | -{ |
|
13 | - /** |
|
11 | + class SessionServiceProvider extends ServiceProvider |
|
12 | + { |
|
13 | + /** |
|
14 | 14 | * Register the Session Service Provider. |
15 | 15 | * |
16 | 16 | * @return void |
17 | 17 | */ |
18 | - public function register() |
|
19 | - { |
|
20 | - $this->app->bind('chocosession', function () { |
|
21 | - return Session::getInstance(); |
|
22 | - }); |
|
18 | + public function register() |
|
19 | + { |
|
20 | + $this->app->bind('chocosession', function () { |
|
21 | + return Session::getInstance(); |
|
22 | + }); |
|
23 | 23 | |
24 | - Session::getInstance()->start(); |
|
25 | - } |
|
24 | + Session::getInstance()->start(); |
|
25 | + } |
|
26 | 26 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function register() |
20 | 20 | { |
21 | - $this->app->bind('choconux', function () { |
|
21 | + $this->app->bind('choconux', function() { |
|
22 | 22 | return Nux::getInstance(); |
23 | 23 | }); |
24 | 24 | } |
@@ -1,24 +1,24 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Providers; |
|
3 | + namespace App\Providers; |
|
4 | 4 | |
5 | -use App\Helpers\Nux; |
|
6 | -use Illuminate\Support\ServiceProvider; |
|
5 | + use App\Helpers\Nux; |
|
6 | + use Illuminate\Support\ServiceProvider; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Class NuxServiceProvider. |
10 | 10 | */ |
11 | -class NuxServiceProvider extends ServiceProvider |
|
12 | -{ |
|
13 | - /** |
|
11 | + class NuxServiceProvider extends ServiceProvider |
|
12 | + { |
|
13 | + /** |
|
14 | 14 | * Register the Session Service Provider. |
15 | 15 | * |
16 | 16 | * @return void |
17 | 17 | */ |
18 | - public function register() |
|
19 | - { |
|
20 | - $this->app->bind('choconux', function () { |
|
21 | - return Nux::getInstance(); |
|
22 | - }); |
|
23 | - } |
|
18 | + public function register() |
|
19 | + { |
|
20 | + $this->app->bind('choconux', function () { |
|
21 | + return Nux::getInstance(); |
|
22 | + }); |
|
23 | + } |
|
24 | 24 | } |
@@ -21,7 +21,6 @@ |
||
21 | 21 | */ |
22 | 22 | public function handle($request, Closure $next) |
23 | 23 | { |
24 | - return Config::get('maintenance.enforce') ? response()->json(['error' => 'maintenance'], 503) : |
|
25 | - $next($request); |
|
24 | + return Config::get('maintenance.enforce') ? response()->json(['error' => 'maintenance'], 503) : $next($request); |
|
26 | 25 | } |
27 | 26 | } |
@@ -1,17 +1,17 @@ discard block |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Http\Middleware; |
|
3 | + namespace App\Http\Middleware; |
|
4 | 4 | |
5 | -use Closure; |
|
6 | -use Illuminate\Http\Request; |
|
7 | -use Illuminate\Support\Facades\Config; |
|
5 | + use Closure; |
|
6 | + use Illuminate\Http\Request; |
|
7 | + use Illuminate\Support\Facades\Config; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Class Maintenance. |
11 | 11 | */ |
12 | -class Maintenance |
|
13 | -{ |
|
14 | - /** |
|
12 | + class Maintenance |
|
13 | + { |
|
14 | + /** |
|
15 | 15 | * Handle an incoming request. |
16 | 16 | * |
17 | 17 | * @param Request $request |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function handle($request, Closure $next) |
|
23 | - { |
|
24 | - return Config::get('maintenance.enforce') ? response()->json(['error' => 'maintenance'], 503) : |
|
25 | - $next($request); |
|
26 | - } |
|
22 | + public function handle($request, Closure $next) |
|
23 | + { |
|
24 | + return Config::get('maintenance.enforce') ? response()->json(['error' => 'maintenance'], 503) : |
|
25 | + $next($request); |
|
26 | + } |
|
27 | 27 | } |
@@ -167,7 +167,7 @@ |
||
167 | 167 | */ |
168 | 168 | public function getTagsAttribute(): array |
169 | 169 | { |
170 | - return array_filter(explode(';', $this->attributes['tags']), function ($element) { |
|
170 | + return array_filter(explode(';', $this->attributes['tags']), function($element) { |
|
171 | 171 | return !empty($element); |
172 | 172 | }); |
173 | 173 | } |
@@ -1,76 +1,76 @@ discard block |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Models; |
|
3 | + namespace App\Models; |
|
4 | 4 | |
5 | -use Illuminate\Database\Eloquent\Model; |
|
6 | -use Illuminate\Support\Facades\Config; |
|
7 | -use Sofa\Eloquence\Eloquence; |
|
8 | -use Sofa\Eloquence\Mappable; |
|
5 | + use Illuminate\Database\Eloquent\Model; |
|
6 | + use Illuminate\Support\Facades\Config; |
|
7 | + use Sofa\Eloquence\Eloquence; |
|
8 | + use Sofa\Eloquence\Mappable; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Class Room. |
12 | 12 | * |
13 | 13 | * @property int id |
14 | 14 | */ |
15 | -class Room extends Model |
|
16 | -{ |
|
17 | - use Eloquence, Mappable; |
|
15 | + class Room extends Model |
|
16 | + { |
|
17 | + use Eloquence, Mappable; |
|
18 | 18 | |
19 | - /** |
|
19 | + /** |
|
20 | 20 | * Disable Timestamps. |
21 | 21 | * |
22 | 22 | * @var bool |
23 | 23 | */ |
24 | - public $timestamps = false; |
|
24 | + public $timestamps = false; |
|
25 | 25 | |
26 | - /** |
|
26 | + /** |
|
27 | 27 | * Leader Board Rank. |
28 | 28 | * |
29 | 29 | * @var int |
30 | 30 | */ |
31 | - public $leaderboardRank = 1; |
|
31 | + public $leaderboardRank = 1; |
|
32 | 32 | |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * The table associated with the model. |
35 | 35 | * |
36 | 36 | * @var string |
37 | 37 | */ |
38 | - protected $table = 'rooms'; |
|
38 | + protected $table = 'rooms'; |
|
39 | 39 | |
40 | - /** |
|
40 | + /** |
|
41 | 41 | * Primary Key of the Table. |
42 | 42 | * |
43 | 43 | * @var string |
44 | 44 | */ |
45 | - protected $primaryKey = 'id'; |
|
45 | + protected $primaryKey = 'id'; |
|
46 | 46 | |
47 | - /** |
|
47 | + /** |
|
48 | 48 | * The attributes that will be mapped. |
49 | 49 | * |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $maps = ['uniqueId' => 'id', 'ownerName' => 'owner_name', 'ownerUniqueId' => 'owner_id', 'doorMode' => 'state', |
|
53 | - 'leaderboardValue' => 'score', 'maximumVisitors' => 'users_max', 'habboGroupId' => 'guild_id', 'rating' => 'score', ]; |
|
52 | + protected $maps = ['uniqueId' => 'id', 'ownerName' => 'owner_name', 'ownerUniqueId' => 'owner_id', 'doorMode' => 'state', |
|
53 | + 'leaderboardValue' => 'score', 'maximumVisitors' => 'users_max', 'habboGroupId' => 'guild_id', 'rating' => 'score', ]; |
|
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * The Appender(s) of the Model. |
57 | 57 | * |
58 | 58 | * @var array |
59 | 59 | */ |
60 | - protected $appends = ['uniqueId', 'leaderboardRank', 'thumbnailUrl', 'imageUrl', 'leaderboardValue', 'doorMode', 'maximumVisitors', |
|
61 | - 'publicRoom', 'ownerUniqueId', 'ownerName', 'showOwnerName', 'categories', 'rating', ]; |
|
60 | + protected $appends = ['uniqueId', 'leaderboardRank', 'thumbnailUrl', 'imageUrl', 'leaderboardValue', 'doorMode', 'maximumVisitors', |
|
61 | + 'publicRoom', 'ownerUniqueId', 'ownerName', 'showOwnerName', 'categories', 'rating', ]; |
|
62 | 62 | |
63 | - /** |
|
63 | + /** |
|
64 | 64 | * The attributes excluded from the model's JSON form. |
65 | 65 | * |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - protected $hidden = ['owner_name', 'owner_id', 'is_public', 'state', 'password', 'model', 'users', 'users_max', 'guild_id', 'category', 'score', 'paper_floor', 'paper_wall', |
|
69 | - 'paper_landscape', 'thickness_wall', 'wall_height', 'thickness_floor', 'moodlight_data', 'is_staff_picked', 'allow_other_pets', 'allow_other_pets_eat', 'allow_walkthrough', |
|
70 | - 'allow_hidewall', 'chat_mode', 'chat_weight', 'chat_speed', 'chat_hearing_distance', 'chat_protection', 'override_model', 'who_can_mute', 'who_can_kick', 'who_can_ban', 'poll_id', |
|
71 | - 'roller_speed', 'promoted', 'trade_mode', 'move_diagonally', ]; |
|
68 | + protected $hidden = ['owner_name', 'owner_id', 'is_public', 'state', 'password', 'model', 'users', 'users_max', 'guild_id', 'category', 'score', 'paper_floor', 'paper_wall', |
|
69 | + 'paper_landscape', 'thickness_wall', 'wall_height', 'thickness_floor', 'moodlight_data', 'is_staff_picked', 'allow_other_pets', 'allow_other_pets_eat', 'allow_walkthrough', |
|
70 | + 'allow_hidewall', 'chat_mode', 'chat_weight', 'chat_speed', 'chat_hearing_distance', 'chat_protection', 'override_model', 'who_can_mute', 'who_can_kick', 'who_can_ban', 'poll_id', |
|
71 | + 'roller_speed', 'promoted', 'trade_mode', 'move_diagonally', ]; |
|
72 | 72 | |
73 | - /** |
|
73 | + /** |
|
74 | 74 | * Stores a new Room. |
75 | 75 | * |
76 | 76 | * @param string $roomName |
@@ -86,113 +86,113 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return Room |
88 | 88 | */ |
89 | - public function store(string $roomName, string $description, string $model, int $maxUsers, int $roomCategory, int $floorPaper, int $wallPaper, float $landscapePaper, int $ownerId, string $ownerName) |
|
90 | - { |
|
91 | - $this->attributes['name'] = $roomName; |
|
92 | - $this->attributes['description'] = $description; |
|
93 | - $this->attributes['model'] = $model; |
|
94 | - $this->attributes['users_max'] = $maxUsers; |
|
95 | - $this->attributes['category'] = $roomCategory; |
|
96 | - $this->attributes['paper_floor'] = $floorPaper; |
|
97 | - $this->attributes['paper_wall'] = $wallPaper; |
|
98 | - $this->attributes['paper_landscape'] = $landscapePaper; |
|
99 | - $this->attributes['thickness_wall'] = 0; |
|
100 | - $this->attributes['wall_height'] = -1; |
|
101 | - $this->attributes['thickness_floor'] = 0; |
|
102 | - $this->attributes['owner_id'] = $ownerId; |
|
103 | - $this->attributes['owner_name'] = $ownerName; |
|
104 | - $this->timestamps = false; |
|
105 | - |
|
106 | - $this->save(); |
|
107 | - |
|
108 | - return $this; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
89 | + public function store(string $roomName, string $description, string $model, int $maxUsers, int $roomCategory, int $floorPaper, int $wallPaper, float $landscapePaper, int $ownerId, string $ownerName) |
|
90 | + { |
|
91 | + $this->attributes['name'] = $roomName; |
|
92 | + $this->attributes['description'] = $description; |
|
93 | + $this->attributes['model'] = $model; |
|
94 | + $this->attributes['users_max'] = $maxUsers; |
|
95 | + $this->attributes['category'] = $roomCategory; |
|
96 | + $this->attributes['paper_floor'] = $floorPaper; |
|
97 | + $this->attributes['paper_wall'] = $wallPaper; |
|
98 | + $this->attributes['paper_landscape'] = $landscapePaper; |
|
99 | + $this->attributes['thickness_wall'] = 0; |
|
100 | + $this->attributes['wall_height'] = -1; |
|
101 | + $this->attributes['thickness_floor'] = 0; |
|
102 | + $this->attributes['owner_id'] = $ownerId; |
|
103 | + $this->attributes['owner_name'] = $ownerName; |
|
104 | + $this->timestamps = false; |
|
105 | + |
|
106 | + $this->save(); |
|
107 | + |
|
108 | + return $this; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | 112 | * Get Room Tags. |
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function getTagsAttribute(): array |
|
117 | - { |
|
118 | - return array_filter(explode(';', $this->attributes['tags']), function ($element) { |
|
119 | - return !empty($element); |
|
120 | - }); |
|
121 | - } |
|
116 | + public function getTagsAttribute(): array |
|
117 | + { |
|
118 | + return array_filter(explode(';', $this->attributes['tags']), function ($element) { |
|
119 | + return !empty($element); |
|
120 | + }); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
123 | + /** |
|
124 | 124 | * Get Image Url. |
125 | 125 | * |
126 | 126 | * @TODO: Get Real Full Room Image |
127 | 127 | * |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public function getImageUrlAttribute(): string |
|
131 | - { |
|
132 | - return "//arcturus.wf/full_{$this->attributes['id']}.png"; |
|
133 | - } |
|
130 | + public function getImageUrlAttribute(): string |
|
131 | + { |
|
132 | + return "//arcturus.wf/full_{$this->attributes['id']}.png"; |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
135 | + /** |
|
136 | 136 | * Get Thumbnail Url. |
137 | 137 | * |
138 | 138 | * @return string |
139 | 139 | */ |
140 | - public function getThumbnailUrlAttribute(): string |
|
141 | - { |
|
142 | - $userName = Config::get('chocolatey.arcturus'); |
|
140 | + public function getThumbnailUrlAttribute(): string |
|
141 | + { |
|
142 | + $userName = Config::get('chocolatey.arcturus'); |
|
143 | 143 | |
144 | - return "//arcturus.wf/camera/{$userName}/thumbnail_{$this->attributes['id']}.png"; |
|
145 | - } |
|
144 | + return "//arcturus.wf/camera/{$userName}/thumbnail_{$this->attributes['id']}.png"; |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
147 | + /** |
|
148 | 148 | * Return if need show Owner Name. |
149 | 149 | * |
150 | 150 | * @TODO: What this really does? |
151 | 151 | * |
152 | 152 | * @return bool |
153 | 153 | */ |
154 | - public function getShowOwnerNameAttribute(): bool |
|
155 | - { |
|
156 | - return true; |
|
157 | - } |
|
154 | + public function getShowOwnerNameAttribute(): bool |
|
155 | + { |
|
156 | + return true; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
159 | + /** |
|
160 | 160 | * Set a Leader Board Position. |
161 | 161 | * |
162 | 162 | * @param int $roomPosition |
163 | 163 | */ |
164 | - public function setLeaderBoardRankAttribute(int $roomPosition = 1) |
|
165 | - { |
|
166 | - $this->leaderboardRank = $roomPosition; |
|
167 | - } |
|
164 | + public function setLeaderBoardRankAttribute(int $roomPosition = 1) |
|
165 | + { |
|
166 | + $this->leaderboardRank = $roomPosition; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
169 | + /** |
|
170 | 170 | * Get Leader Board Rank. |
171 | 171 | * |
172 | 172 | * @return int |
173 | 173 | */ |
174 | - public function getLeaderBoardRankAttribute(): int |
|
175 | - { |
|
176 | - return $this->leaderboardRank; |
|
177 | - } |
|
174 | + public function getLeaderBoardRankAttribute(): int |
|
175 | + { |
|
176 | + return $this->leaderboardRank; |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
179 | + /** |
|
180 | 180 | * Get if the Room is Public. |
181 | 181 | * |
182 | 182 | * @return bool |
183 | 183 | */ |
184 | - public function getPublicRoomAttribute(): bool |
|
185 | - { |
|
186 | - return $this->attributes['is_public'] == 1; |
|
187 | - } |
|
184 | + public function getPublicRoomAttribute(): bool |
|
185 | + { |
|
186 | + return $this->attributes['is_public'] == 1; |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
189 | + /** |
|
190 | 190 | * Get Room Category. |
191 | 191 | * |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - public function getCategoriesAttribute(): array |
|
195 | - { |
|
196 | - return [str_replace('}', '', str_replace('${', '', FlatCat::find($this->attributes['category'])->caption))]; |
|
197 | - } |
|
194 | + public function getCategoriesAttribute(): array |
|
195 | + { |
|
196 | + return [str_replace('}', '', str_replace('${', '', FlatCat::find($this->attributes['category'])->caption))]; |
|
197 | + } |
|
198 | 198 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | if (!Config::get('mail.enable')) |
25 | 25 | return; |
26 | 26 | |
27 | - Mail::send($view, $configuration, function ($message) use ($configuration) { |
|
27 | + Mail::send($view, $configuration, function($message) use ($configuration) { |
|
28 | 28 | $message->from(Config::get('mail.from.address'), Config::get('mail.from.name')); |
29 | 29 | $message->to($configuration['email'])->subject($configuration['subject']); |
30 | 30 | }); |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function send(array $configuration, string $view = 'habbo-web-mail.confirm-mail') |
23 | 23 | { |
24 | - if (!Config::get('mail.enable')) |
|
25 | - return; |
|
24 | + if (!Config::get('mail.enable')) { |
|
25 | + return; |
|
26 | + } |
|
26 | 27 | |
27 | 28 | Mail::send($view, $configuration, function ($message) use ($configuration) { |
28 | 29 | $message->from(Config::get('mail.from.address'), Config::get('mail.from.name')); |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | { |
55 | 56 | $mailRequest = MailModel::where('token', $token)->where('used', '0')->first(); |
56 | 57 | |
57 | - if ($mailRequest !== null) |
|
58 | - $mailRequest->update(['used' => '1']); |
|
58 | + if ($mailRequest !== null) { |
|
59 | + $mailRequest->update(['used' => '1']); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | return $mailRequest; |
61 | 63 | } |
@@ -1,62 +1,62 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Http\Controllers; |
|
3 | + namespace App\Http\Controllers; |
|
4 | 4 | |
5 | -use App\Models\Mail as MailModel; |
|
6 | -use Illuminate\Support\Facades\Config; |
|
7 | -use Illuminate\Support\Facades\Mail; |
|
8 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
5 | + use App\Models\Mail as MailModel; |
|
6 | + use Illuminate\Support\Facades\Config; |
|
7 | + use Illuminate\Support\Facades\Mail; |
|
8 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Class MailController |
12 | 12 | * @package App\Http\Controllers |
13 | 13 | */ |
14 | -class MailController extends BaseController |
|
15 | -{ |
|
16 | - /** |
|
14 | + class MailController extends BaseController |
|
15 | + { |
|
16 | + /** |
|
17 | 17 | * Send an Email |
18 | 18 | * |
19 | 19 | * @param array $configuration |
20 | 20 | * @param string $view |
21 | 21 | */ |
22 | - public function send(array $configuration, string $view = 'habbo-web-mail.confirm-mail') |
|
23 | - { |
|
24 | - if (!Config::get('mail.enable')) |
|
25 | - return; |
|
26 | - |
|
27 | - Mail::send($view, $configuration, function ($message) use ($configuration) { |
|
28 | - $message->from(Config::get('mail.from.address'), Config::get('mail.from.name')); |
|
29 | - $message->to($configuration['email'])->subject($configuration['subject']); |
|
30 | - }); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
22 | + public function send(array $configuration, string $view = 'habbo-web-mail.confirm-mail') |
|
23 | + { |
|
24 | + if (!Config::get('mail.enable')) |
|
25 | + return; |
|
26 | + |
|
27 | + Mail::send($view, $configuration, function ($message) use ($configuration) { |
|
28 | + $message->from(Config::get('mail.from.address'), Config::get('mail.from.name')); |
|
29 | + $message->to($configuration['email'])->subject($configuration['subject']); |
|
30 | + }); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | 34 | * Prepare the E-Mail |
35 | 35 | * |
36 | 36 | * @param string $email |
37 | 37 | * @param string $url |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function prepare(string $email, string $url): string |
|
41 | - { |
|
42 | - (new MailModel)->store($token = uniqid('HabboMail', true), $url, $email)->save(); |
|
40 | + public function prepare(string $email, string $url): string |
|
41 | + { |
|
42 | + (new MailModel)->store($token = uniqid('HabboMail', true), $url, $email)->save(); |
|
43 | 43 | |
44 | - return $token; |
|
45 | - } |
|
44 | + return $token; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
47 | + /** |
|
48 | 48 | * Get E-Mail by Controller |
49 | 49 | * |
50 | 50 | * @param string $token |
51 | 51 | * @return object |
52 | 52 | */ |
53 | - public function getMail(string $token) |
|
54 | - { |
|
55 | - $mailRequest = MailModel::where('token', $token)->where('used', '0')->first(); |
|
53 | + public function getMail(string $token) |
|
54 | + { |
|
55 | + $mailRequest = MailModel::where('token', $token)->where('used', '0')->first(); |
|
56 | 56 | |
57 | - if ($mailRequest !== null) |
|
58 | - $mailRequest->update(['used' => '1']); |
|
57 | + if ($mailRequest !== null) |
|
58 | + $mailRequest->update(['used' => '1']); |
|
59 | 59 | |
60 | - return $mailRequest; |
|
61 | - } |
|
60 | + return $mailRequest; |
|
61 | + } |
|
62 | 62 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function register() |
20 | 20 | { |
21 | - $this->app->bind('chocouser', function () { |
|
21 | + $this->app->bind('chocouser', function() { |
|
22 | 22 | return User::getInstance(); |
23 | 23 | }); |
24 | 24 | } |
@@ -1,24 +1,24 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Providers; |
|
3 | + namespace App\Providers; |
|
4 | 4 | |
5 | -use App\Helpers\User; |
|
6 | -use Illuminate\Support\ServiceProvider; |
|
5 | + use App\Helpers\User; |
|
6 | + use Illuminate\Support\ServiceProvider; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Class UserServiceProvider. |
10 | 10 | */ |
11 | -class UserServiceProvider extends ServiceProvider |
|
12 | -{ |
|
13 | - /** |
|
11 | + class UserServiceProvider extends ServiceProvider |
|
12 | + { |
|
13 | + /** |
|
14 | 14 | * Register the Session Service Provider. |
15 | 15 | * |
16 | 16 | * @return void |
17 | 17 | */ |
18 | - public function register() |
|
19 | - { |
|
20 | - $this->app->bind('chocouser', function () { |
|
21 | - return User::getInstance(); |
|
22 | - }); |
|
23 | - } |
|
18 | + public function register() |
|
19 | + { |
|
20 | + $this->app->bind('chocouser', function () { |
|
21 | + return User::getInstance(); |
|
22 | + }); |
|
23 | + } |
|
24 | 24 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function register() |
20 | 20 | { |
21 | - $this->app->bind('chocomail', function () { |
|
21 | + $this->app->bind('chocomail', function() { |
|
22 | 22 | return Mail::getInstance(); |
23 | 23 | }); |
24 | 24 | } |
@@ -1,24 +1,24 @@ |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Providers; |
|
3 | + namespace App\Providers; |
|
4 | 4 | |
5 | -use App\Helpers\Mail; |
|
6 | -use Illuminate\Support\ServiceProvider; |
|
5 | + use App\Helpers\Mail; |
|
6 | + use Illuminate\Support\ServiceProvider; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Class MailServiceProvider. |
10 | 10 | */ |
11 | -class MailServiceProvider extends ServiceProvider |
|
12 | -{ |
|
13 | - /** |
|
11 | + class MailServiceProvider extends ServiceProvider |
|
12 | + { |
|
13 | + /** |
|
14 | 14 | * Register the Session Service Provider. |
15 | 15 | * |
16 | 16 | * @return void |
17 | 17 | */ |
18 | - public function register() |
|
19 | - { |
|
20 | - $this->app->bind('chocomail', function () { |
|
21 | - return Mail::getInstance(); |
|
22 | - }); |
|
23 | - } |
|
18 | + public function register() |
|
19 | + { |
|
20 | + $this->app->bind('chocomail', function () { |
|
21 | + return Mail::getInstance(); |
|
22 | + }); |
|
23 | + } |
|
24 | 24 | } |
@@ -200,7 +200,7 @@ |
||
200 | 200 | * |
201 | 201 | * @param Request $request |
202 | 202 | * |
203 | - * @return mixed |
|
203 | + * @return JsonResponse |
|
204 | 204 | */ |
205 | 205 | public function confirmChangePassword(Request $request): JsonResponse |
206 | 206 | { |
@@ -1,89 +1,89 @@ discard block |
||
1 | -<?php |
|
2 | - |
|
3 | -namespace App\Http\Controllers; |
|
4 | - |
|
5 | -use App\Facades\Mail; |
|
6 | -use App\Facades\User as UserFacade; |
|
7 | -use App\Models\ChocolateyId; |
|
8 | -use App\Models\Question; |
|
9 | -use App\Models\TrustedDevice; |
|
10 | -use App\Models\User; |
|
11 | -use App\Models\UserSecurity; |
|
12 | -use Illuminate\Http\JsonResponse; |
|
13 | -use Illuminate\Http\Request; |
|
14 | -use Illuminate\Http\Response; |
|
15 | -use Illuminate\Support\Facades\Config; |
|
16 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
1 | + <?php |
|
2 | + |
|
3 | + namespace App\Http\Controllers; |
|
4 | + |
|
5 | + use App\Facades\Mail; |
|
6 | + use App\Facades\User as UserFacade; |
|
7 | + use App\Models\ChocolateyId; |
|
8 | + use App\Models\Question; |
|
9 | + use App\Models\TrustedDevice; |
|
10 | + use App\Models\User; |
|
11 | + use App\Models\UserSecurity; |
|
12 | + use Illuminate\Http\JsonResponse; |
|
13 | + use Illuminate\Http\Request; |
|
14 | + use Illuminate\Http\Response; |
|
15 | + use Illuminate\Support\Facades\Config; |
|
16 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Class AccountSecurityController. |
20 | 20 | */ |
21 | -class AccountSecurityController extends BaseController |
|
22 | -{ |
|
23 | - /** |
|
21 | + class AccountSecurityController extends BaseController |
|
22 | + { |
|
23 | + /** |
|
24 | 24 | * Check if Feature Status is Enabled. |
25 | 25 | * |
26 | 26 | * @return Response |
27 | 27 | */ |
28 | - public function featureStatus(): Response |
|
29 | - { |
|
30 | - if (UserFacade::getUser()->emailVerified == false) { |
|
31 | - return response('identity_verification_required', 200); |
|
32 | - } |
|
28 | + public function featureStatus(): Response |
|
29 | + { |
|
30 | + if (UserFacade::getUser()->emailVerified == false) { |
|
31 | + return response('identity_verification_required', 200); |
|
32 | + } |
|
33 | 33 | |
34 | - $featureEnabled = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
34 | + $featureEnabled = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
35 | 35 | |
36 | - return response($featureEnabled !== null ? 'enabled' : 'disabled', 200); |
|
37 | - } |
|
36 | + return response($featureEnabled !== null ? 'enabled' : 'disabled', 200); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
39 | + /** |
|
40 | 40 | * Save Security Questions. |
41 | 41 | * |
42 | 42 | * @param Request $request |
43 | 43 | * |
44 | 44 | * @return JsonResponse |
45 | 45 | */ |
46 | - public function saveQuestions(Request $request): JsonResponse |
|
47 | - { |
|
48 | - if (UserFacade::getUser()->getChocolateyId()->password != hash(Config::get('chocolatey.security.hash'), $request->json()->get('password'))) { |
|
49 | - return response()->json(['error' => 'invalid_password'], 400); |
|
50 | - } |
|
51 | - |
|
52 | - UserSecurity::updateOrCreate([ |
|
53 | - 'user_id' => UserFacade::getUser()->uniqueId, |
|
54 | - 'firstQuestion' => $request->json()->get('questionId1'), |
|
55 | - 'secondQuestion' => $request->json()->get('questionId2'), |
|
56 | - 'firstAnswer' => $request->json()->get('answer1'), |
|
57 | - 'secondAnswer' => $request->json()->get('answer2'), ]); |
|
58 | - |
|
59 | - return response()->json(null, 204); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
46 | + public function saveQuestions(Request $request): JsonResponse |
|
47 | + { |
|
48 | + if (UserFacade::getUser()->getChocolateyId()->password != hash(Config::get('chocolatey.security.hash'), $request->json()->get('password'))) { |
|
49 | + return response()->json(['error' => 'invalid_password'], 400); |
|
50 | + } |
|
51 | + |
|
52 | + UserSecurity::updateOrCreate([ |
|
53 | + 'user_id' => UserFacade::getUser()->uniqueId, |
|
54 | + 'firstQuestion' => $request->json()->get('questionId1'), |
|
55 | + 'secondQuestion' => $request->json()->get('questionId2'), |
|
56 | + 'firstAnswer' => $request->json()->get('answer1'), |
|
57 | + 'secondAnswer' => $request->json()->get('answer2'), ]); |
|
58 | + |
|
59 | + return response()->json(null, 204); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | 63 | * Disable Safety Lock. |
64 | 64 | * |
65 | 65 | * @return JsonResponse |
66 | 66 | */ |
67 | - public function disable(): JsonResponse |
|
68 | - { |
|
69 | - UserSecurity::find(UserFacade::getUser()->uniqueId)->delete(); |
|
67 | + public function disable(): JsonResponse |
|
68 | + { |
|
69 | + UserSecurity::find(UserFacade::getUser()->uniqueId)->delete(); |
|
70 | 70 | |
71 | - return response()->json(null, 204); |
|
72 | - } |
|
71 | + return response()->json(null, 204); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
74 | + /** |
|
75 | 75 | * Reset Trusted Devices. |
76 | 76 | * |
77 | 77 | * @return JsonResponse |
78 | 78 | */ |
79 | - public function reset(): JsonResponse |
|
80 | - { |
|
81 | - TrustedDevice::find(UserFacade::getUser()->uniqueId)->delete(); |
|
79 | + public function reset(): JsonResponse |
|
80 | + { |
|
81 | + TrustedDevice::find(UserFacade::getUser()->uniqueId)->delete(); |
|
82 | 82 | |
83 | - return response()->json(null, 204); |
|
84 | - } |
|
83 | + return response()->json(null, 204); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
86 | + /** |
|
87 | 87 | * Change User Password. |
88 | 88 | * |
89 | 89 | * @TODO: Implement Notification E-mail of Password change |
@@ -92,139 +92,139 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return JsonResponse |
94 | 94 | */ |
95 | - public function changePassword(Request $request): JsonResponse |
|
96 | - { |
|
97 | - UserFacade::getUser()->getChocolateyId()->update(['password' => hash(Config::get('chocolatey.security.hash'), |
|
98 | - $request->json()->get('password'))]); |
|
95 | + public function changePassword(Request $request): JsonResponse |
|
96 | + { |
|
97 | + UserFacade::getUser()->getChocolateyId()->update(['password' => hash(Config::get('chocolatey.security.hash'), |
|
98 | + $request->json()->get('password'))]); |
|
99 | 99 | |
100 | - return response()->json(null, 204); |
|
101 | - } |
|
100 | + return response()->json(null, 204); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
103 | + /** |
|
104 | 104 | * Confirm E-Mail Activation. |
105 | 105 | * |
106 | 106 | * @param Request $request |
107 | 107 | * |
108 | 108 | * @return JsonResponse |
109 | 109 | */ |
110 | - public function confirmActivation(Request $request): JsonResponse |
|
111 | - { |
|
112 | - if (Mail::get($request->json()->get('token')) == null) { |
|
113 | - return response()->json(['error' => 'activation.invalid_token'], 400); |
|
114 | - } |
|
110 | + public function confirmActivation(Request $request): JsonResponse |
|
111 | + { |
|
112 | + if (Mail::get($request->json()->get('token')) == null) { |
|
113 | + return response()->json(['error' => 'activation.invalid_token'], 400); |
|
114 | + } |
|
115 | 115 | |
116 | - ChocolateyId::find(Mail::get()->mail)->update(['mail_verified' => '1']); |
|
116 | + ChocolateyId::find(Mail::get()->mail)->update(['mail_verified' => '1']); |
|
117 | 117 | |
118 | - if (strpos(Mail::get()->link, 'change-email') !== false) { |
|
119 | - $email = str_replace('change-email/', '', Mail::get()->link); |
|
118 | + if (strpos(Mail::get()->link, 'change-email') !== false) { |
|
119 | + $email = str_replace('change-email/', '', Mail::get()->link); |
|
120 | 120 | |
121 | - User::where('mail', Mail::get()->mail)->update(['mail' => $email]); |
|
121 | + User::where('mail', Mail::get()->mail)->update(['mail' => $email]); |
|
122 | 122 | |
123 | - ChocolateyId::find(Mail::get()->mail)->update(['mail' => $email]); |
|
124 | - } |
|
123 | + ChocolateyId::find(Mail::get()->mail)->update(['mail' => $email]); |
|
124 | + } |
|
125 | 125 | |
126 | - return response()->json(['email' => Mail::get()->mail, 'emailVerified' => true, 'identityVerified' => true]); |
|
127 | - } |
|
126 | + return response()->json(['email' => Mail::get()->mail, 'emailVerified' => true, 'identityVerified' => true]); |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
129 | + /** |
|
130 | 130 | * Change User E-mail. |
131 | 131 | * |
132 | 132 | * @param Request $request |
133 | 133 | * |
134 | 134 | * @return JsonResponse |
135 | 135 | */ |
136 | - public function changeMail(Request $request): JsonResponse |
|
137 | - { |
|
138 | - if (User::where('password', hash(Config::get('chocolatey.security.hash'), $request->json()->get('currentPassword')))->count() == 0) { |
|
139 | - return response()->json(['error' => 'changeEmail.invalid_password'], 400); |
|
140 | - } |
|
136 | + public function changeMail(Request $request): JsonResponse |
|
137 | + { |
|
138 | + if (User::where('password', hash(Config::get('chocolatey.security.hash'), $request->json()->get('currentPassword')))->count() == 0) { |
|
139 | + return response()->json(['error' => 'changeEmail.invalid_password'], 400); |
|
140 | + } |
|
141 | 141 | |
142 | - if (ChocolateyId::where('mail', $request->json()->get('newEmail'))->count() > 0) { |
|
143 | - return response()->json(['error' => 'changeEmail.email_already_in_use'], 400); |
|
144 | - } |
|
142 | + if (ChocolateyId::where('mail', $request->json()->get('newEmail'))->count() > 0) { |
|
143 | + return response()->json(['error' => 'changeEmail.email_already_in_use'], 400); |
|
144 | + } |
|
145 | 145 | |
146 | - $this->sendChangeMailConfirmation($request); |
|
146 | + $this->sendChangeMailConfirmation($request); |
|
147 | 147 | |
148 | - return response()->json(['email' => $request->json()->get('newEmail')], 200); |
|
149 | - } |
|
148 | + return response()->json(['email' => $request->json()->get('newEmail')], 200); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
151 | + /** |
|
152 | 152 | * Send the E-Mail confirmation. |
153 | 153 | * |
154 | 154 | * @param Request $request |
155 | 155 | */ |
156 | - protected function sendChangeMailConfirmation(Request $request) |
|
157 | - { |
|
158 | - Mail::send(['email' => UserFacade::getUser()->email, |
|
159 | - 'name' => UserFacade::getUser()->name, 'subject' => 'Email change alert', |
|
160 | - ], 'habbo-web-mail.mail-change-alert'); |
|
156 | + protected function sendChangeMailConfirmation(Request $request) |
|
157 | + { |
|
158 | + Mail::send(['email' => UserFacade::getUser()->email, |
|
159 | + 'name' => UserFacade::getUser()->name, 'subject' => 'Email change alert', |
|
160 | + ], 'habbo-web-mail.mail-change-alert'); |
|
161 | 161 | |
162 | - $generatedToken = Mail::store(UserFacade::getUser()->email, |
|
163 | - "change-email/{$request->json()->get('newEmail')}"); |
|
162 | + $generatedToken = Mail::store(UserFacade::getUser()->email, |
|
163 | + "change-email/{$request->json()->get('newEmail')}"); |
|
164 | 164 | |
165 | - Mail::send(['email' => $request->json()->get('newEmail'), 'name' => UserFacade::getUser()->name, |
|
166 | - 'subject' => 'Email change confirmation', 'url' => "/activate/{$generatedToken}", |
|
167 | - ], 'habbo-web-mail.confirm-mail-change'); |
|
168 | - } |
|
165 | + Mail::send(['email' => $request->json()->get('newEmail'), 'name' => UserFacade::getUser()->name, |
|
166 | + 'subject' => 'Email change confirmation', 'url' => "/activate/{$generatedToken}", |
|
167 | + ], 'habbo-web-mail.confirm-mail-change'); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
170 | + /** |
|
171 | 171 | * Get User Security Questions. |
172 | 172 | * |
173 | 173 | * @return JsonResponse |
174 | 174 | */ |
175 | - public function getQuestions(): JsonResponse |
|
176 | - { |
|
177 | - if (UserSecurity::find(UserFacade::getUser()->uniqueId) == null) { |
|
178 | - return response()->json(''); |
|
179 | - } |
|
180 | - |
|
181 | - $userSecurity = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
182 | - |
|
183 | - return response()->json([ |
|
184 | - new Question($userSecurity->firstQuestion, |
|
185 | - "IDENTITY_SAFETYQUESTION_{$userSecurity->firstQuestion}"), |
|
186 | - new Question($userSecurity->secondQuestion, |
|
187 | - "IDENTITY_SAFETYQUESTION_{$userSecurity->secondQuestion}"), |
|
188 | - ]); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
175 | + public function getQuestions(): JsonResponse |
|
176 | + { |
|
177 | + if (UserSecurity::find(UserFacade::getUser()->uniqueId) == null) { |
|
178 | + return response()->json(''); |
|
179 | + } |
|
180 | + |
|
181 | + $userSecurity = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
182 | + |
|
183 | + return response()->json([ |
|
184 | + new Question($userSecurity->firstQuestion, |
|
185 | + "IDENTITY_SAFETYQUESTION_{$userSecurity->firstQuestion}"), |
|
186 | + new Question($userSecurity->secondQuestion, |
|
187 | + "IDENTITY_SAFETYQUESTION_{$userSecurity->secondQuestion}"), |
|
188 | + ]); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | 192 | * Verify User Security Questions. |
193 | 193 | * |
194 | 194 | * @param Request $request |
195 | 195 | * |
196 | 196 | * @return JsonResponse |
197 | 197 | */ |
198 | - public function verifyQuestions(Request $request): JsonResponse |
|
199 | - { |
|
200 | - $questions = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
198 | + public function verifyQuestions(Request $request): JsonResponse |
|
199 | + { |
|
200 | + $questions = UserSecurity::find(UserFacade::getUser()->uniqueId); |
|
201 | 201 | |
202 | - if ($questions->firstAnswer == $request->json()->get('answer1') && $questions->secondAnswer == $request->json()->get('answer2')) { |
|
203 | - if ($request->json()->get('trust') == true) { |
|
204 | - (new TrustedDevice())->store(UserFacade::getUser()->uniqueId, $request->ip()); |
|
205 | - } |
|
202 | + if ($questions->firstAnswer == $request->json()->get('answer1') && $questions->secondAnswer == $request->json()->get('answer2')) { |
|
203 | + if ($request->json()->get('trust') == true) { |
|
204 | + (new TrustedDevice())->store(UserFacade::getUser()->uniqueId, $request->ip()); |
|
205 | + } |
|
206 | 206 | |
207 | - return response()->json(null, 204); |
|
208 | - } |
|
207 | + return response()->json(null, 204); |
|
208 | + } |
|
209 | 209 | |
210 | - return response()->json(null, 409); |
|
211 | - } |
|
210 | + return response()->json(null, 409); |
|
211 | + } |
|
212 | 212 | |
213 | - /** |
|
213 | + /** |
|
214 | 214 | * Confirm User Change Password. |
215 | 215 | * |
216 | 216 | * @param Request $request |
217 | 217 | * |
218 | 218 | * @return mixed |
219 | 219 | */ |
220 | - public function confirmChangePassword(Request $request): JsonResponse |
|
221 | - { |
|
222 | - if (Mail::get($request->json()->get('token')) == null) { |
|
223 | - return response()->json(null, 404); |
|
224 | - } |
|
220 | + public function confirmChangePassword(Request $request): JsonResponse |
|
221 | + { |
|
222 | + if (Mail::get($request->json()->get('token')) == null) { |
|
223 | + return response()->json(null, 404); |
|
224 | + } |
|
225 | 225 | |
226 | - ChocolateyId::find(Mail::get()->mail)->update(['password' => hash(Config::get('chocolatey.security.hash'), $request->json()->get('password'))]); |
|
226 | + ChocolateyId::find(Mail::get()->mail)->update(['password' => hash(Config::get('chocolatey.security.hash'), $request->json()->get('password'))]); |
|
227 | 227 | |
228 | - return response()->json(null); |
|
229 | - } |
|
228 | + return response()->json(null); |
|
229 | + } |
|
230 | 230 | } |