|
|
@ -2,14 +2,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Auth; |
|
|
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Hash; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\User; |
|
|
|
|
|
|
|
use App\Models\Role; |
|
|
|
use App\Models\Role; |
|
|
|
|
|
|
|
use App\Models\User; |
|
|
|
use App\Models\Company; |
|
|
|
use App\Models\Company; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Str; |
|
|
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Auth; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Hash; |
|
|
|
use Illuminate\Support\Facades\Password; |
|
|
|
use Illuminate\Support\Facades\Password; |
|
|
|
use Illuminate\Validation\ValidationException; |
|
|
|
use Illuminate\Validation\ValidationException; |
|
|
|
|
|
|
|
|
|
|
@ -18,7 +19,7 @@ class AuthController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function __construct() |
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->middleware('auth:api', ['except' => ['login']]); |
|
|
|
$this->middleware('auth:api', ['except' => ['login','sendEmail']]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function login(Request $request) |
|
|
|
public function login(Request $request) |
|
|
@ -114,13 +115,12 @@ class AuthController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
$hashed = Str::random(15); |
|
|
|
$hashed = Str::random(15); |
|
|
|
$email = $request->email; |
|
|
|
$email = $request->email; |
|
|
|
$user = User::select('email', 'name')->where('email', $email)->first(); |
|
|
|
$user = User::select('email', 'name', 'username')->where('email', $email)->first(); |
|
|
|
|
|
|
|
|
|
|
|
if (!$user) { |
|
|
|
if (!$user || empty($email)) { |
|
|
|
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
|
|
|
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->reqHttpCurl($email, $hashed, $user->username, $user->name); |
|
|
|
$this->reqHttpCurl($email, $hashed, $user->username, $user->name); |
|
|
|
// $updateUser = User::where('email', $email)->update(['password'=> $hashed]); |
|
|
|
|
|
|
|
if (User::where('email', $email)->update(['password' => md5($hashed)])) |
|
|
|
if (User::where('email', $email)->update(['password' => md5($hashed)])) |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200); |
|
|
|
|
|
|
|
|
|
|
|