I am facing this issue though I am submitting the correct code on laravel.
public function loginCodeCheck(Request $request)
{
try {
$user = User::find(auth()->id());
$telegramSession = $user->telegramSession;
$madelineProto = $this->factory->get($telegramSession);
$secret_code = $request->code;
$madelineProto->completePhoneLogin($secret_code);
return redirect()->route('user.add.product')->with('success', 'You have successfully logged in to Telegram, Now you can add or edit product.');
} catch (\Throwable $th) {
return redirect()->route('user.telegram.login')->with('error', $th->getMessage());
}
}
public function loginCheckAjax(Request $request)
{
$validator = Validator::make($request->all(), [
'phone' => 'required',
]);
if (!$validator->passes()) {
return response()->json(['error' => $validator->errors()->all()]);
}
try {
$user = User::find(auth()->id());
TelegramSession::where('user_id', $user->id)->delete();
File::delete(File::glob(storage_path("app/telegram/" . $user->id . "*")));
$telegramSession = $user->telegramSession()->create([
'session_file' => "{$user->id}.madeline"
]);
$madelineProto = $this->factory->get($telegramSession);
$phone = $request->phone;
$madelineProto->phoneLogin($phone);
return response(['codesent' => 1], 200);
} catch (\Throwable $th) {
$user = User::find(auth()->id());
if ($user->telegramSession) {
$session = $user->telegramSession->orderBy('id', 'desc')->first();
if ($session != null) {
File::delete(File::glob(storage_path("app/telegram/" . $session->session_file . "*")));
$user->telegramSession->delete();
}
}
if ($th->getMessage() == 'PHONE_NUMBER_INVALID') {
return response()->json(['error' => 'You phone number is not registered or is banned on Telegram. Use another phone number.']);
} else {
return response()->json(['error' => $th->getMessage()]);
}
}
}
This is the function. I didn't try without mysql, I need always multisession, I am currently using telegram_session table in database to save session and file being save in storage/app/telegram folder
I am facing this issue though I am submitting the correct code on laravel.
public function loginCodeCheck(Request $request) {
}
public function loginCheckAjax(Request $request) { $validator = Validator::make($request->all(), [ 'phone' => 'required', ]);
}
This is the function. I didn't try without mysql, I need always multisession, I am currently using telegram_session table in database to save session and file being save in storage/app/telegram folder