403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/apache/htdocs/app/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/apache/htdocs/app/app/Http/Controllers/AuthController.php.save.1
<?php

namespace App\Http\Controllers;

use App\Http\Requests\Auths\ByPassLoginRequest;
use App\Http\Requests\Auths\EditPasswordRequest;
use App\Http\Requests\Auths\UpdateProfileRequest;
use App\Http\Requests\Auths\LoginRequest;
use App\Http\Requests\Auths\RegisterRequest;
use App\Http\Requests\Auths\ForgotPasswordRequest;
use App\Http\Requests\Auths\ResetPasswordRequest;
use App\Http\Services\AuthService;
use App\Http\Services\UserService;
use App\Models\User;
use DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;


class AuthController extends Controller
{	

	public function __construct(
		AuthService $authService,
		UserService $userService
	)
	{
		$this->authService = $authService;
		$this->userService = $userService;
	}

	/**
	* @OA\Post(
	*
	*	path="/api/auth/login",
	*	operationId="loginDefault",
	*	tags={"Auth"},
	*	summary="Login User",
	*	security={
	*		{
	*			"open_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="email",
	*		description="Email",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="student1"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="password",
	*		description="Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="device_name",
	*		description="Device Name",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="swagger"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="fcm_token",
	*		description="fcm_token",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="platform",
	*		description="platform",
	*		in="query",
	*		@OA\Schema(
	*			type="enum",
	*			default="",
	*			enum={"ios", "android", "web"}
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function login(Request $request)
	{
info($request);
		$token = $this->authService->login( $request->validated() );
		return self::successResponse("Success",[
			"token" => $token->plainTextToken, // use by mobile team
			"user" => Auth::user(),
		])->header('Authorization', $token->plainTextToken ); // use by web
	}

	/**
	* @OA\Post(
	*
	*	path="/api/auth/knight",
	*	operationId="login - knight",
	*	tags={"Auth"},
	*	summary="Login Knight",
	*	security={
	*		{
	*			"open_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="id",
	*		description="id",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="full_name",
	*		description="full_name",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="email",
	*		description="email",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="secret",
	*		description="secret",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="device_name",
	*		description="Device Name",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="swagger"
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function byPassLogin(ByPassLoginRequest $request)
	{
		$token = $this->authService->byPassLogin( $request->validated() );

		return self::successResponse("Success",[
			"token" => $token->plainTextToken, // use by mobile team
			"user" => Auth::user(),
		])->header('Authorization', $token->plainTextToken ); // use by web
	}

	/**
	* @OA\Post(
	*
	*	path="/api/auth/register",
	*	operationId="register",
	*	tags={"Auth"},
	*	summary="Register",
	*	security={
	*		{
	*			"open_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="full_name",
	*		description="full_name",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="student1"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="email",
	*		description="email",
	*		in="query",
	*		@OA\Schema(
	*			type="string"
	*		)
	*	),
	*   @OA\Parameter(
	*       name="mobile_num",
	*       description="mobile_num",
	*       in="query",
	*       @OA\Schema(
	*           type="string",
	*           default=""
	*       )
	*   ),
	*	@OA\Parameter(
	*		name="password",
	*		description="Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="password_confirmation",
	*		description="Confirm Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="device_name",
	*		description="device_name ( if set, will auto login and return token )",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="swagger"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="fcm_token",
	*		description="fcm_token",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Parameter(
	*		name="platform",
	*		description="platform",
	*		in="query",
	*		@OA\Schema(
	*			type="enum",
	*			default="",
	*			enum={"ios", "android"}
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function register(RegisterRequest $request)
	{
		$payload = $request->validated();
		$payload['role_id'] = User::ROLE_CUSTOMER;
		$result = $this->authService->register( $payload );

		if(isset($payload['device_name'])){
			return self::successResponse("Success",[
				"token" => $result->plainTextToken, // use by mobile team
				"user" => Auth::user(),
			])->header('Authorization', $result->plainTextToken ); // use by web
		}

		return self::successResponse("Success", [
			"user" => $result
		]);
	}

	/**
	* @OA\Put(
	*
	*	path="/api/auth/update",
	*	operationId="update",
	*	tags={"Auth"},
	*	summary="Edit Profile",
	*	security={
	*		{
	*			"open_key": {}
	*		},
	*		{
	*			"api_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="full_name",
	*		description="full_name",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="student1"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="mobile_num",
	*		description="mobile_num",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function authUpdate(UpdateProfileRequest $request)
	{
		$payload = array_merge( $request->validated(),[
			'id' => Auth::id()
		]);
		$user = $this->userService->userUpdate( $payload );

		return self::successResponse("Success", [
			"user" => $user
		]);
	}

	/**
	* @OA\Get(
	*
	*	path="/api/auth/user",
	*	operationId="user",
	*	tags={"Auth"},
	*	summary="Get Auth User",
	*	security={
	*		{
	*			"open_key": {}
	*		},
	*		{
	*			"api_key": {}
	*		}
	*	},
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function user()
	{	
		$result = $this->authService->user();

		return self::successResponse("Success",$result);
	}

	/**
	* @OA\Delete(
	*
	*	path="/api/auth/logout",
	*	operationId="logout",
	*	tags={"Auth"},
	*	summary="Logout",
	*	security={
	*		{
	*			"open_key": {}
	*		},
	*		{
	*			"api_key": {}
	*		}
	*	},
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function logout()
	{
		$result = $this->authService->logout();

		return self::successResponse("Success",$result);
	}

	/**
	* @OA\Get(
	*
	*	path="/api/auth/check-password",
	*	operationId="checkAuthPassword",
	*	tags={"Auth"},
	*	summary="Check Auth Password",
	*	security={
	*		{
	*			"open_key": {}
	*		},
	*		{
	*			"api_key": {}
	*		}
	*	},
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function checkAuthPassword()
	{
		$has_old_password = Auth::user()->isContainOldPassword();

		return self::successResponse('Success',[
			'has_old_password' => $has_old_password
		]);
	}

	/**
	* @OA\Put(
	*
	*	path="/api/auth/edit-password",
	*	operationId="editPassword",
	*	tags={"Auth"},
	*	summary="Edit Password",
	*	security={
	*		{
	*			"open_key": {}
	*		},
	*		{
	*			"api_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="current_password",
	*		description="current Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="password",
	*		description="Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Parameter(
	*		name="password_confirmation",
	*		description="Confirm Password",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default="12345678"
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function editAuthPassword(EditPasswordRequest $request)
	{
		$status = DB::transaction(function () use ($request){
			return $this->authService->editAuthPassword( $request->validated() );
		});
		return self::successResponse("Success", $status);
	}

	/**
	* @OA\Post(
	*
	*	path="/api/auth/forgot-password",
	*	operationId="forgotPassword",
	*	tags={"Auth"},
	*	summary="Forgot Password by email",
	*	security={
	*		{
	*			"open_key": {}
	*		}
	*	},
	*	@OA\Parameter(
	*		name="email",
	*		description="email",
	*		in="query",
	*		@OA\Schema(
	*			type="string",
	*			default=""
	*		)
	*	),
	*	@OA\Response(
	*		response=200,
	*		description="Success",
	*		@OA\JsonContent()
	*	),
	*	@OA\Response(response=400, description="Bad request"),
	*	@OA\Response(response=404, description="Resource Not Found"),
	*	@OA\Response(response=422, description="Unprocessable Entity"),
	*	@OA\Response(response=500, description="Internal Server Error"),
	* )
	*/
	public function forgotPassword(ForgotPasswordRequest $request)
	{
		$result = $this->userService->forgotPassword( $request->validated() );

		return self::successResponse("Success", [
			'email' => $result
		]);
	}

	public function resetPassword(ResetPasswordRequest $request)
	{
		$result = $this->userService->resetPassword( $request->validated() );

		return self::successResponse("Success", $result);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit