@@ -1,30 +1,30 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class Voucher. |
| 7 | 7 | */ |
| 8 | -class Voucher extends ChocolateyModel |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class Voucher extends ChocolateyModel |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Disable Timestamps. |
| 12 | 12 | * |
| 13 | 13 | * @var bool |
| 14 | 14 | */ |
| 15 | - public $timestamps = false; |
|
| 15 | + public $timestamps = false; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * The table associated with the model. |
| 19 | 19 | * |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $table = 'vouchers'; |
|
| 22 | + protected $table = 'vouchers'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Primary Key of the Table. |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $primaryKey = 'id'; |
|
| 29 | + protected $primaryKey = 'id'; |
|
| 30 | 30 | } |
@@ -1,44 +1,44 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class PurchaseParam. |
| 7 | 7 | */ |
| 8 | -class PurchaseParam |
|
| 9 | -{ |
|
| 10 | - /** |
|
| 8 | + class PurchaseParam |
|
| 9 | + { |
|
| 10 | + /** |
|
| 11 | 11 | * Country Id. |
| 12 | 12 | * |
| 13 | 13 | * @var int |
| 14 | 14 | */ |
| 15 | - public $countryId; |
|
| 15 | + public $countryId; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Price Point Id. |
| 19 | 19 | * |
| 20 | 20 | * @var int |
| 21 | 21 | */ |
| 22 | - public $pricePointId; |
|
| 22 | + public $pricePointId; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | + /** |
|
| 25 | 25 | * Payment Method Id. |
| 26 | 26 | * |
| 27 | 27 | * @var int |
| 28 | 28 | */ |
| 29 | - public $paymentMethodId; |
|
| 29 | + public $paymentMethodId; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Create a new Purchase Param. |
| 33 | 33 | * |
| 34 | 34 | * @param int $countryId |
| 35 | 35 | * @param int $pricePointId |
| 36 | 36 | * @param int $paymentMethodId |
| 37 | 37 | */ |
| 38 | - public function __construct(int $countryId, int $pricePointId, int $paymentMethodId) |
|
| 39 | - { |
|
| 40 | - $this->countryId = $countryId; |
|
| 41 | - $this->pricePointId = $pricePointId; |
|
| 42 | - $this->paymentMethodId = $paymentMethodId; |
|
| 43 | - } |
|
| 38 | + public function __construct(int $countryId, int $pricePointId, int $paymentMethodId) |
|
| 39 | + { |
|
| 40 | + $this->countryId = $countryId; |
|
| 41 | + $this->pricePointId = $pricePointId; |
|
| 42 | + $this->paymentMethodId = $paymentMethodId; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -1,80 +1,80 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Models; |
|
| 3 | + namespace App\Models; |
|
| 4 | 4 | |
| 5 | -use Sofa\Eloquence\Eloquence; |
|
| 6 | -use Sofa\Eloquence\Mappable; |
|
| 5 | + use Sofa\Eloquence\Eloquence; |
|
| 6 | + use Sofa\Eloquence\Mappable; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class UserGroup. |
| 10 | 10 | */ |
| 11 | -class UserGroup extends ChocolateyModel |
|
| 12 | -{ |
|
| 13 | - use Eloquence, Mappable; |
|
| 11 | + class UserGroup extends ChocolateyModel |
|
| 12 | + { |
|
| 13 | + use Eloquence, Mappable; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 15 | + /** |
|
| 16 | 16 | * Disable Timestamps. |
| 17 | 17 | * |
| 18 | 18 | * @var bool |
| 19 | 19 | */ |
| 20 | - public $timestamps = false; |
|
| 20 | + public $timestamps = false; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | + /** |
|
| 23 | 23 | * The table associated with the model. |
| 24 | 24 | * |
| 25 | 25 | * @var string |
| 26 | 26 | */ |
| 27 | - protected $table = 'guilds'; |
|
| 27 | + protected $table = 'guilds'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | + /** |
|
| 30 | 30 | * Primary Key of the Table. |
| 31 | 31 | * |
| 32 | 32 | * @var string |
| 33 | 33 | */ |
| 34 | - protected $primaryKey = 'id'; |
|
| 34 | + protected $primaryKey = 'id'; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | + /** |
|
| 37 | 37 | * The attributes that will be mapped. |
| 38 | 38 | * |
| 39 | 39 | * @var array |
| 40 | 40 | */ |
| 41 | - protected $maps = ['badgeCode' => 'badge', 'roomId' => 'room_id', 'primaryColour' => 'color_one', 'secondaryColour' => 'color_two']; |
|
| 41 | + protected $maps = ['badgeCode' => 'badge', 'roomId' => 'room_id', 'primaryColour' => 'color_one', 'secondaryColour' => 'color_two']; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | + /** |
|
| 44 | 44 | * The attributes excluded from the model's JSON form. |
| 45 | 45 | * |
| 46 | 46 | * @var array |
| 47 | 47 | */ |
| 48 | - protected $hidden = ['user_id', 'badge', 'slot_id', 'id', 'user_id', 'room_id', 'state', 'rights', 'forum', 'date_created', 'read_forum', 'post_messages', 'post_threads', 'mod_forum']; |
|
| 48 | + protected $hidden = ['user_id', 'badge', 'slot_id', 'id', 'user_id', 'room_id', 'state', 'rights', 'forum', 'date_created', 'read_forum', 'post_messages', 'post_threads', 'mod_forum']; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * The Appender(s) of the Model. |
| 52 | 52 | * |
| 53 | 53 | * @var array |
| 54 | 54 | */ |
| 55 | - protected $appends = ['badgeCode', 'roomId', 'primaryColour', 'secondaryColour', 'type', 'isAdmin']; |
|
| 55 | + protected $appends = ['badgeCode', 'roomId', 'primaryColour', 'secondaryColour', 'type', 'isAdmin']; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | + /** |
|
| 58 | 58 | * Return if is Admin. |
| 59 | 59 | * |
| 60 | 60 | * @TODO: Link with User Data |
| 61 | 61 | * |
| 62 | 62 | * @return bool |
| 63 | 63 | */ |
| 64 | - public function getIsAdminAttribute(): bool |
|
| 65 | - { |
|
| 66 | - return false; |
|
| 67 | - } |
|
| 64 | + public function getIsAdminAttribute(): bool |
|
| 65 | + { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | + /** |
|
| 70 | 70 | * Get the Group Type. |
| 71 | 71 | * |
| 72 | 72 | * @TODO: What NORMAL means? |
| 73 | 73 | * |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - public function getTypeAttribute(): string |
|
| 77 | - { |
|
| 78 | - return 'NORMAL'; |
|
| 79 | - } |
|
| 76 | + public function getTypeAttribute(): string |
|
| 77 | + { |
|
| 78 | + return 'NORMAL'; |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\User as UserFacade; |
|
| 6 | -use App\Models\Photo; |
|
| 7 | -use App\Models\PhotoLike; |
|
| 8 | -use App\Models\PhotoReport; |
|
| 9 | -use Illuminate\Http\JsonResponse; |
|
| 10 | -use Illuminate\Http\Request; |
|
| 11 | -use Illuminate\Http\Response; |
|
| 12 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use App\Facades\User as UserFacade; |
|
| 6 | + use App\Models\Photo; |
|
| 7 | + use App\Models\PhotoLike; |
|
| 8 | + use App\Models\PhotoReport; |
|
| 9 | + use Illuminate\Http\JsonResponse; |
|
| 10 | + use Illuminate\Http\Request; |
|
| 11 | + use Illuminate\Http\Response; |
|
| 12 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Class PhotosController. |
| 16 | 16 | */ |
| 17 | -class PhotosController extends BaseController |
|
| 18 | -{ |
|
| 19 | - /** |
|
| 17 | + class PhotosController extends BaseController |
|
| 18 | + { |
|
| 19 | + /** |
|
| 20 | 20 | * Render a set of Public HabboWEB Photos. |
| 21 | 21 | * |
| 22 | 22 | * @TODO: Exclude Approved Reported Photos from the List |
| 23 | 23 | * |
| 24 | 24 | * @return JsonResponse |
| 25 | 25 | */ |
| 26 | - public function show(): JsonResponse |
|
| 27 | - { |
|
| 28 | - return response()->json(Photo::all(), 200, [], JSON_UNESCAPED_SLASHES); |
|
| 29 | - } |
|
| 26 | + public function show(): JsonResponse |
|
| 27 | + { |
|
| 28 | + return response()->json(Photo::all(), 200, [], JSON_UNESCAPED_SLASHES); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * Register a Report of a Photo |
| 33 | 33 | * Observation.: We will not create a limit of max reports. |
| 34 | 34 | * Since it's a retro we don't really care about reports. |
@@ -40,66 +40,66 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return Response |
| 42 | 42 | */ |
| 43 | - public function report(Request $request, int $photoId): Response |
|
| 44 | - { |
|
| 45 | - (new PhotoReport())->store($photoId, $request->json()->get('reason'), UserFacade::getUser()->uniqueId); |
|
| 43 | + public function report(Request $request, int $photoId): Response |
|
| 44 | + { |
|
| 45 | + (new PhotoReport())->store($photoId, $request->json()->get('reason'), UserFacade::getUser()->uniqueId); |
|
| 46 | 46 | |
| 47 | - return response(null); |
|
| 48 | - } |
|
| 47 | + return response(null); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * Like a Photo. |
| 52 | 52 | * |
| 53 | 53 | * @param int $photoId |
| 54 | 54 | * |
| 55 | 55 | * @return Response |
| 56 | 56 | */ |
| 57 | - public function likePhoto(int $photoId): Response |
|
| 58 | - { |
|
| 59 | - if (PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->count() > 0) { |
|
| 60 | - return response(null); |
|
| 61 | - } |
|
| 57 | + public function likePhoto(int $photoId): Response |
|
| 58 | + { |
|
| 59 | + if (PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->count() > 0) { |
|
| 60 | + return response(null); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - (new PhotoLike())->store($photoId, UserFacade::getUser()->name); |
|
| 63 | + (new PhotoLike())->store($photoId, UserFacade::getUser()->name); |
|
| 64 | 64 | |
| 65 | - return response(null); |
|
| 66 | - } |
|
| 65 | + return response(null); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 68 | + /** |
|
| 69 | 69 | * Unlike a Photo. |
| 70 | 70 | * |
| 71 | 71 | * @param int $photoId |
| 72 | 72 | * |
| 73 | 73 | * @return Response |
| 74 | 74 | */ |
| 75 | - public function unlikePhoto(int $photoId): Response |
|
| 76 | - { |
|
| 77 | - if (PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->count() == 0) { |
|
| 78 | - return response(null); |
|
| 79 | - } |
|
| 75 | + public function unlikePhoto(int $photoId): Response |
|
| 76 | + { |
|
| 77 | + if (PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->count() == 0) { |
|
| 78 | + return response(null); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->delete(); |
|
| 81 | + PhotoLike::where('username', UserFacade::getUser()->name)->where('photo_id', $photoId)->delete(); |
|
| 82 | 82 | |
| 83 | - return response(null); |
|
| 84 | - } |
|
| 83 | + return response(null); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | + /** |
|
| 87 | 87 | * Delete a Photo. |
| 88 | 88 | * |
| 89 | 89 | * @param int $photoId |
| 90 | 90 | * |
| 91 | 91 | * @return Response |
| 92 | 92 | */ |
| 93 | - public function delete(int $photoId): Response |
|
| 94 | - { |
|
| 95 | - $photo = Photo::find($photoId); |
|
| 93 | + public function delete(int $photoId): Response |
|
| 94 | + { |
|
| 95 | + $photo = Photo::find($photoId); |
|
| 96 | 96 | |
| 97 | - if ($photo == null || $photo->creator_id != UserFacade::getUser()->uniqueId) { |
|
| 98 | - return response(null, 401); |
|
| 99 | - } |
|
| 97 | + if ($photo == null || $photo->creator_id != UserFacade::getUser()->uniqueId) { |
|
| 98 | + return response(null, 401); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - $photo->delete(); |
|
| 101 | + $photo->delete(); |
|
| 102 | 102 | |
| 103 | - return response(null); |
|
| 104 | - } |
|
| 103 | + return response(null); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -1,65 +1,65 @@ 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\Country; |
|
| 8 | -use App\Models\PaymentCheckout; |
|
| 9 | -use App\Models\Purse; |
|
| 10 | -use App\Models\ShopHistory; |
|
| 11 | -use App\Models\ShopInventory; |
|
| 12 | -use App\Models\ShopItem; |
|
| 13 | -use App\Models\Voucher; |
|
| 14 | -use Illuminate\Http\JsonResponse; |
|
| 15 | -use Illuminate\Http\RedirectResponse; |
|
| 16 | -use Illuminate\Http\Request; |
|
| 17 | -use Illuminate\Http\Response; |
|
| 18 | -use Laravel\Lumen\Http\Redirector; |
|
| 19 | -use Laravel\Lumen\Http\ResponseFactory; |
|
| 20 | -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\Country; |
|
| 8 | + use App\Models\PaymentCheckout; |
|
| 9 | + use App\Models\Purse; |
|
| 10 | + use App\Models\ShopHistory; |
|
| 11 | + use App\Models\ShopInventory; |
|
| 12 | + use App\Models\ShopItem; |
|
| 13 | + use App\Models\Voucher; |
|
| 14 | + use Illuminate\Http\JsonResponse; |
|
| 15 | + use Illuminate\Http\RedirectResponse; |
|
| 16 | + use Illuminate\Http\Request; |
|
| 17 | + use Illuminate\Http\Response; |
|
| 18 | + use Laravel\Lumen\Http\Redirector; |
|
| 19 | + use Laravel\Lumen\Http\ResponseFactory; |
|
| 20 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Class ShopController. |
| 24 | 24 | */ |
| 25 | -class ShopController extends BaseController |
|
| 26 | -{ |
|
| 27 | - /** |
|
| 25 | + class ShopController extends BaseController |
|
| 26 | + { |
|
| 27 | + /** |
|
| 28 | 28 | * List all Shop Countries. |
| 29 | 29 | * |
| 30 | 30 | * @return JsonResponse |
| 31 | 31 | */ |
| 32 | - public function listCountries(): JsonResponse |
|
| 33 | - { |
|
| 34 | - return response()->json(Country::all()); |
|
| 35 | - } |
|
| 32 | + public function listCountries(): JsonResponse |
|
| 33 | + { |
|
| 34 | + return response()->json(Country::all()); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | + /** |
|
| 38 | 38 | * Get the Shop Inventory of a Country. |
| 39 | 39 | * |
| 40 | 40 | * @param string $countryCode |
| 41 | 41 | * |
| 42 | 42 | * @return JsonResponse |
| 43 | 43 | */ |
| 44 | - public function getInventory(string $countryCode): JsonResponse |
|
| 45 | - { |
|
| 46 | - return response()->json(new ShopInventory(Country::where('countryCode', $countryCode)->first()), |
|
| 47 | - 200, [], JSON_UNESCAPED_SLASHES); |
|
| 48 | - } |
|
| 44 | + public function getInventory(string $countryCode): JsonResponse |
|
| 45 | + { |
|
| 46 | + return response()->json(new ShopInventory(Country::where('countryCode', $countryCode)->first()), |
|
| 47 | + 200, [], JSON_UNESCAPED_SLASHES); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * Get User Purse. |
| 52 | 52 | * |
| 53 | 53 | * @param Request $request |
| 54 | 54 | * |
| 55 | 55 | * @return JsonResponse |
| 56 | 56 | */ |
| 57 | - public function getPurse(Request $request): JsonResponse |
|
| 58 | - { |
|
| 59 | - return response()->json(new Purse(UserFacade::getUser()->uniqueId)); |
|
| 60 | - } |
|
| 57 | + public function getPurse(Request $request): JsonResponse |
|
| 58 | + { |
|
| 59 | + return response()->json(new Purse(UserFacade::getUser()->uniqueId)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | + /** |
|
| 63 | 63 | * Proceed Payment Checkout. |
| 64 | 64 | * |
| 65 | 65 | * @param string $paymentCategory |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return RedirectResponse|Response|Redirector|ResponseFactory |
| 71 | 71 | */ |
| 72 | - public function proceed(string $paymentCategory, int $countryCode, int $shopItem, int $paymentMethod) |
|
| 73 | - { |
|
| 74 | - $paymentCheckout = PaymentCheckout::where('category', $paymentCategory)->where('country', $countryCode) |
|
| 75 | - ->where('item', $shopItem)->where('method', $paymentMethod)->first(); |
|
| 72 | + public function proceed(string $paymentCategory, int $countryCode, int $shopItem, int $paymentMethod) |
|
| 73 | + { |
|
| 74 | + $paymentCheckout = PaymentCheckout::where('category', $paymentCategory)->where('country', $countryCode) |
|
| 75 | + ->where('item', $shopItem)->where('method', $paymentMethod)->first(); |
|
| 76 | 76 | |
| 77 | - if ($paymentCheckout == null) { |
|
| 78 | - return response(view('habbo-web-payments.failed-payment'), 400); |
|
| 79 | - } |
|
| 77 | + if ($paymentCheckout == null) { |
|
| 78 | + return response(view('habbo-web-payments.failed-payment'), 400); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ((strtotime($paymentCheckout->generated_at) + 172800) < time()) { |
|
| 82 | - return response(view('habbo-web-payments.canceled-payment'), 400); |
|
| 83 | - } |
|
| 81 | + if ((strtotime($paymentCheckout->generated_at) + 172800) < time()) { |
|
| 82 | + return response(view('habbo-web-payments.canceled-payment'), 400); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return response(view('habbo-web-payments.proceed', ['payment' => $paymentCheckout])); |
|
| 86 | - } |
|
| 85 | + return response(view('habbo-web-payments.proceed', ['payment' => $paymentCheckout])); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | + /** |
|
| 89 | 89 | * Success Payment Checkout. |
| 90 | 90 | * |
| 91 | 91 | * @TODO: Code Business Logic |
@@ -98,27 +98,27 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return RedirectResponse|Response|Redirector|ResponseFactory |
| 100 | 100 | */ |
| 101 | - public function success(Request $request, string $paymentCategory, int $countryCode, int $shopItem, int $paymentMethod) |
|
| 102 | - { |
|
| 103 | - $paymentCheckout = PaymentCheckout::where('category', $paymentCategory)->where('country', $countryCode) |
|
| 104 | - ->where('item', $shopItem)->where('method', $paymentMethod)->first(); |
|
| 101 | + public function success(Request $request, string $paymentCategory, int $countryCode, int $shopItem, int $paymentMethod) |
|
| 102 | + { |
|
| 103 | + $paymentCheckout = PaymentCheckout::where('category', $paymentCategory)->where('country', $countryCode) |
|
| 104 | + ->where('item', $shopItem)->where('method', $paymentMethod)->first(); |
|
| 105 | 105 | |
| 106 | - if ($paymentCheckout == null) { |
|
| 107 | - return response(view('habbo-web-payments.canceled-payment'), 500); |
|
| 108 | - } |
|
| 106 | + if ($paymentCheckout == null) { |
|
| 107 | + return response(view('habbo-web-payments.canceled-payment'), 500); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - $purchaseItem = (new ShopHistory())->store($paymentMethod, UserFacade::getUser()->uniqueId, $shopItem); |
|
| 110 | + $purchaseItem = (new ShopHistory())->store($paymentMethod, UserFacade::getUser()->uniqueId, $shopItem); |
|
| 111 | 111 | |
| 112 | - Mail::send(['email' => UserFacade::getUser()->email, 'purchaseId' => $purchaseItem->transactionId, |
|
| 113 | - 'product' => ShopItem::find($shopItem), 'subject' => 'Purchase completed', |
|
| 114 | - ], 'habbo-web-mail.purchase-confirmation'); |
|
| 112 | + Mail::send(['email' => UserFacade::getUser()->email, 'purchaseId' => $purchaseItem->transactionId, |
|
| 113 | + 'product' => ShopItem::find($shopItem), 'subject' => 'Purchase completed', |
|
| 114 | + ], 'habbo-web-mail.purchase-confirmation'); |
|
| 115 | 115 | |
| 116 | - $paymentCheckout->delete(); |
|
| 116 | + $paymentCheckout->delete(); |
|
| 117 | 117 | |
| 118 | - return response(view('habbo-web-payments.success-payment', ['checkoutId' => $purchaseItem->transactionId]), 200); |
|
| 119 | - } |
|
| 118 | + return response(view('habbo-web-payments.success-payment', ['checkoutId' => $purchaseItem->transactionId]), 200); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 121 | + /** |
|
| 122 | 122 | * Get User Purchase History. |
| 123 | 123 | * |
| 124 | 124 | * @TODO: User Purchase History will be coded on the Future |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return JsonResponse |
| 129 | 129 | */ |
| 130 | - public function getHistory(): JsonResponse |
|
| 131 | - { |
|
| 132 | - return response()->json(ShopHistory::where('user_id', UserFacade::getUser()->uniqueId)->get()); |
|
| 133 | - } |
|
| 130 | + public function getHistory(): JsonResponse |
|
| 131 | + { |
|
| 132 | + return response()->json(ShopHistory::where('user_id', UserFacade::getUser()->uniqueId)->get()); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 135 | + /** |
|
| 136 | 136 | * Redeem Voucher. |
| 137 | 137 | * |
| 138 | 138 | * @TODO: Need to Test if really works |
@@ -141,17 +141,17 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @return JsonResponse |
| 143 | 143 | */ |
| 144 | - public function redeem(Request $request): JsonResponse |
|
| 145 | - { |
|
| 146 | - if (($voucher = Voucher::where('code', $request->json()->get('voucherCode'))->first()) == null) { |
|
| 147 | - return response()->json(null, 404); |
|
| 148 | - } |
|
| 144 | + public function redeem(Request $request): JsonResponse |
|
| 145 | + { |
|
| 146 | + if (($voucher = Voucher::where('code', $request->json()->get('voucherCode'))->first()) == null) { |
|
| 147 | + return response()->json(null, 404); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - UserFacade::getUser()->increment('credits', $voucher->credits); |
|
| 151 | - UserFacade::getUser()->increment('pixels', $voucher->points); |
|
| 150 | + UserFacade::getUser()->increment('credits', $voucher->credits); |
|
| 151 | + UserFacade::getUser()->increment('pixels', $voucher->points); |
|
| 152 | 152 | |
| 153 | - $voucher->delete(); |
|
| 153 | + $voucher->delete(); |
|
| 154 | 154 | |
| 155 | - return response()->json(null, 204); |
|
| 156 | - } |
|
| 155 | + return response()->json(null, 204); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -1,106 +1,106 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\User as UserFacade; |
|
| 6 | -use App\Models\Photo; |
|
| 7 | -use App\Models\User; |
|
| 8 | -use App\Models\UserBadge; |
|
| 9 | -use App\Models\UserPreferences; |
|
| 10 | -use App\Models\UserProfile; |
|
| 11 | -use Illuminate\Http\JsonResponse; |
|
| 12 | -use Illuminate\Http\Request; |
|
| 13 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use App\Facades\User as UserFacade; |
|
| 6 | + use App\Models\Photo; |
|
| 7 | + use App\Models\User; |
|
| 8 | + use App\Models\UserBadge; |
|
| 9 | + use App\Models\UserPreferences; |
|
| 10 | + use App\Models\UserProfile; |
|
| 11 | + use Illuminate\Http\JsonResponse; |
|
| 12 | + use Illuminate\Http\Request; |
|
| 13 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Class ProfileController. |
| 17 | 17 | */ |
| 18 | -class ProfileController extends BaseController |
|
| 19 | -{ |
|
| 20 | - /** |
|
| 18 | + class ProfileController extends BaseController |
|
| 19 | + { |
|
| 20 | + /** |
|
| 21 | 21 | * Get Public User Data. |
| 22 | 22 | * |
| 23 | 23 | * @param Request $request |
| 24 | 24 | * |
| 25 | 25 | * @return JsonResponse |
| 26 | 26 | */ |
| 27 | - public function getPublicData(Request $request): JsonResponse |
|
| 28 | - { |
|
| 29 | - $userData = User::where('username', $request->input('name'))->first(); |
|
| 27 | + public function getPublicData(Request $request): JsonResponse |
|
| 28 | + { |
|
| 29 | + $userData = User::where('username', $request->input('name'))->first(); |
|
| 30 | 30 | |
| 31 | - if ($userData == null || $userData->isBanned) { |
|
| 32 | - return response()->json(null, 404); |
|
| 33 | - } |
|
| 31 | + if ($userData == null || $userData->isBanned) { |
|
| 32 | + return response()->json(null, 404); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $userPreferences = UserPreferences::find($userData->uniqueId); |
|
| 35 | + $userPreferences = UserPreferences::find($userData->uniqueId); |
|
| 36 | 36 | |
| 37 | - $userData->selectedBadges = UserBadge::where('user_id', $userData->uniqueId)->where('slot_id', '>', 0)->orderBy('slot_id', 'ASC')->get() ?? []; |
|
| 38 | - $userData->profileVisible = $userPreferences == null ? true : $userPreferences->profileVisible == '1'; |
|
| 37 | + $userData->selectedBadges = UserBadge::where('user_id', $userData->uniqueId)->where('slot_id', '>', 0)->orderBy('slot_id', 'ASC')->get() ?? []; |
|
| 38 | + $userData->profileVisible = $userPreferences == null ? true : $userPreferences->profileVisible == '1'; |
|
| 39 | 39 | |
| 40 | - return response()->json($userData); |
|
| 41 | - } |
|
| 40 | + return response()->json($userData); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | + /** |
|
| 44 | 44 | * Get Public User Profile. |
| 45 | 45 | * |
| 46 | 46 | * @param int $userId |
| 47 | 47 | * |
| 48 | 48 | * @return JsonResponse |
| 49 | 49 | */ |
| 50 | - public function getPublicProfile($userId): JsonResponse |
|
| 51 | - { |
|
| 52 | - $userData = User::find($userId); |
|
| 50 | + public function getPublicProfile($userId): JsonResponse |
|
| 51 | + { |
|
| 52 | + $userData = User::find($userId); |
|
| 53 | 53 | |
| 54 | - if ($userData == null || $userData->isBanned) { |
|
| 55 | - return response()->json(null, 404); |
|
| 56 | - } |
|
| 54 | + if ($userData == null || $userData->isBanned) { |
|
| 55 | + return response()->json(null, 404); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $userPreferences = UserPreferences::find($userData->uniqueId); |
|
| 58 | + $userPreferences = UserPreferences::find($userData->uniqueId); |
|
| 59 | 59 | |
| 60 | - if ($userPreferences != null && $userPreferences->profileVisible == '0') { |
|
| 61 | - return response()->json(null, 404); |
|
| 62 | - } |
|
| 60 | + if ($userPreferences != null && $userPreferences->profileVisible == '0') { |
|
| 61 | + return response()->json(null, 404); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return response()->json(new UserProfile($userData)); |
|
| 65 | - } |
|
| 64 | + return response()->json(new UserProfile($userData)); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | + /** |
|
| 68 | 68 | * Get Private User Profile. |
| 69 | 69 | * |
| 70 | 70 | * @return JsonResponse |
| 71 | 71 | */ |
| 72 | - public function getProfile(): JsonResponse |
|
| 73 | - { |
|
| 74 | - return response()->json(new UserProfile(UserFacade::getUser())); |
|
| 75 | - } |
|
| 72 | + public function getProfile(): JsonResponse |
|
| 73 | + { |
|
| 74 | + return response()->json(new UserProfile(UserFacade::getUser())); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 77 | + /** |
|
| 78 | 78 | * Get User Stories. |
| 79 | 79 | * |
| 80 | 80 | * @TODO: Implement Habbo Stories |
| 81 | 81 | * |
| 82 | 82 | * @return JsonResponse |
| 83 | 83 | */ |
| 84 | - public function getStories(): JsonResponse |
|
| 85 | - { |
|
| 86 | - return response()->json([]); |
|
| 87 | - } |
|
| 84 | + public function getStories(): JsonResponse |
|
| 85 | + { |
|
| 86 | + return response()->json([]); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | + /** |
|
| 90 | 90 | * Get User Photos. |
| 91 | 91 | * |
| 92 | 92 | * @param int $userId |
| 93 | 93 | * |
| 94 | 94 | * @return JsonResponse |
| 95 | 95 | */ |
| 96 | - public function getPhotos(int $userId): JsonResponse |
|
| 97 | - { |
|
| 98 | - if (Photo::where('creator_id', $userId)->count() == 0) { |
|
| 99 | - return response()->json([]); |
|
| 100 | - } |
|
| 96 | + public function getPhotos(int $userId): JsonResponse |
|
| 97 | + { |
|
| 98 | + if (Photo::where('creator_id', $userId)->count() == 0) { |
|
| 99 | + return response()->json([]); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $userPhotos = Photo::where('creator_id', $userId)->get(); |
|
| 102 | + $userPhotos = Photo::where('creator_id', $userId)->get(); |
|
| 103 | 103 | |
| 104 | - return response()->json($userPhotos); |
|
| 105 | - } |
|
| 104 | + return response()->json($userPhotos); |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -1,73 +1,73 @@ |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use App\Facades\Nux; |
|
| 6 | -use App\Facades\User as UserFacade; |
|
| 7 | -use App\Facades\Validation; |
|
| 8 | -use App\Models\NuxValidation; |
|
| 9 | -use App\Models\User; |
|
| 10 | -use Illuminate\Http\JsonResponse; |
|
| 11 | -use Illuminate\Http\Request; |
|
| 12 | -use Illuminate\Http\Response; |
|
| 13 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use App\Facades\Nux; |
|
| 6 | + use App\Facades\User as UserFacade; |
|
| 7 | + use App\Facades\Validation; |
|
| 8 | + use App\Models\NuxValidation; |
|
| 9 | + use App\Models\User; |
|
| 10 | + use Illuminate\Http\JsonResponse; |
|
| 11 | + use Illuminate\Http\Request; |
|
| 12 | + use Illuminate\Http\Response; |
|
| 13 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Class NuxController. |
| 17 | 17 | */ |
| 18 | -class NuxController extends BaseController |
|
| 19 | -{ |
|
| 20 | - /** |
|
| 18 | + class NuxController extends BaseController |
|
| 19 | + { |
|
| 20 | + /** |
|
| 21 | 21 | * Check an User Name. |
| 22 | 22 | * |
| 23 | 23 | * @param Request $request |
| 24 | 24 | * |
| 25 | 25 | * @return JsonResponse |
| 26 | 26 | */ |
| 27 | - public function checkName(Request $request): JsonResponse |
|
| 28 | - { |
|
| 29 | - if (User::where('username', $request->json()->get('name'))->where('id', '<>', UserFacade::getUser()->uniqueId)->count() > 0) { |
|
| 30 | - return response()->json(new NuxValidation('NAME_IN_USE')); |
|
| 31 | - } |
|
| 27 | + public function checkName(Request $request): JsonResponse |
|
| 28 | + { |
|
| 29 | + if (User::where('username', $request->json()->get('name'))->where('id', '<>', UserFacade::getUser()->uniqueId)->count() > 0) { |
|
| 30 | + return response()->json(new NuxValidation('NAME_IN_USE')); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - if (!Validation::filterUserName($request->json()->get('name'))) { |
|
| 34 | - return response()->json(new NuxValidation('INVALID_NAME', ['resultType' => 'VALIDATION_ERROR_ILLEGAL_WORDS'])); |
|
| 35 | - } |
|
| 33 | + if (!Validation::filterUserName($request->json()->get('name'))) { |
|
| 34 | + return response()->json(new NuxValidation('INVALID_NAME', ['resultType' => 'VALIDATION_ERROR_ILLEGAL_WORDS'])); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return response()->json(new NuxValidation()); |
|
| 38 | - } |
|
| 37 | + return response()->json(new NuxValidation()); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | + /** |
|
| 41 | 41 | * Select an User Name. |
| 42 | 42 | * |
| 43 | 43 | * @param Request $request |
| 44 | 44 | * |
| 45 | 45 | * @return JsonResponse |
| 46 | 46 | */ |
| 47 | - public function selectName(Request $request): JsonResponse |
|
| 48 | - { |
|
| 49 | - UserFacade::updateSession(['username' => $request->json()->get('name')]); |
|
| 47 | + public function selectName(Request $request): JsonResponse |
|
| 48 | + { |
|
| 49 | + UserFacade::updateSession(['username' => $request->json()->get('name')]); |
|
| 50 | 50 | |
| 51 | - return response()->json(new NuxValidation()); |
|
| 52 | - } |
|
| 51 | + return response()->json(new NuxValidation()); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | + /** |
|
| 55 | 55 | * Select a Room. |
| 56 | 56 | * |
| 57 | 57 | * @param Request $request |
| 58 | 58 | * |
| 59 | 59 | * @return Response |
| 60 | 60 | */ |
| 61 | - public function selectRoom(Request $request): Response |
|
| 62 | - { |
|
| 63 | - if (!in_array($request->json()->get('roomIndex'), [1, 2, 3])) { |
|
| 64 | - return response('', 400); |
|
| 65 | - } |
|
| 61 | + public function selectRoom(Request $request): Response |
|
| 62 | + { |
|
| 63 | + if (!in_array($request->json()->get('roomIndex'), [1, 2, 3])) { |
|
| 64 | + return response('', 400); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - Nux::generateRoom($request); |
|
| 67 | + Nux::generateRoom($request); |
|
| 68 | 68 | |
| 69 | - UserFacade::getUser()->traits = ['USER']; |
|
| 69 | + UserFacade::getUser()->traits = ['USER']; |
|
| 70 | 70 | |
| 71 | - return response(null, 200); |
|
| 72 | - } |
|
| 71 | + return response(null, 200); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | |
| 3 | -namespace App\Http\Controllers; |
|
| 3 | + namespace App\Http\Controllers; |
|
| 4 | 4 | |
| 5 | -use Illuminate\Http\Response; |
|
| 6 | -use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 5 | + use Illuminate\Http\Response; |
|
| 6 | + use Laravel\Lumen\Routing\Controller as BaseController; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class PageController. |
| 10 | 10 | */ |
| 11 | -class PageController extends BaseController |
|
| 12 | -{ |
|
| 13 | - /** |
|
| 11 | + class PageController extends BaseController |
|
| 12 | + { |
|
| 13 | + /** |
|
| 14 | 14 | * Render a HabboWEB Page. |
| 15 | 15 | * |
| 16 | 16 | * @param string $pageCategory |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return Response |
| 20 | 20 | */ |
| 21 | - public function show(string $pageCategory, string $pageFile): Response |
|
| 22 | - { |
|
| 23 | - $pageArray = explode('.', $pageFile); |
|
| 21 | + public function show(string $pageCategory, string $pageFile): Response |
|
| 22 | + { |
|
| 23 | + $pageArray = explode('.', $pageFile); |
|
| 24 | 24 | |
| 25 | - return response(view("habbo-web-pages.{$pageCategory}.{$pageArray[0]}")); |
|
| 26 | - } |
|
| 25 | + return response(view("habbo-web-pages.{$pageCategory}.{$pageArray[0]}")); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | + /** |
|
| 29 | 29 | * Render a HabboPage. |
| 30 | 30 | * |
| 31 | 31 | * @WARNING: Categories can still be pages |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return Response |
| 37 | 37 | */ |
| 38 | - public function habboPage(string $category, string $page = '') |
|
| 39 | - { |
|
| 40 | - return response(view(empty($page) ? "habbo-pages.{$category}" : "habbo-pages.{$category}.{$page}")); |
|
| 41 | - } |
|
| 38 | + public function habboPage(string $category, string $page = '') |
|
| 39 | + { |
|
| 40 | + return response(view(empty($page) ? "habbo-pages.{$category}" : "habbo-pages.{$category}.{$page}")); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -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 | } |