setiawanhu/laravel-madeline-proto

Wrong Example in the documentation

Opened this issue · 0 comments

Hi!
In the documentation, There is an example for new session when user is logging in:

public function newSession(Request $request) {
    //Insert the session into the telegram_sessions table

    $user = User::find($request->get('user_id'));
    
    $telegramSession = $user->telegramSession()->create([
        'session_file' => "{$user->name}.madeline"
    ]);
    
    //You can either use one of this following method

    $madelineProto = $this->factory->get($telegramSession);
    //or
    $madelineProto = Factory::get($telegramSession);

    $madelineProto->phoneLogin($request->get('phone_number'));

    return response()->json([
        'message' => 'Phone code sent!'
    ]);
}

At the beginning of the function, It gets user_id from the request.
If we know the user_id, Why do we need to authenticate the user?

Assuming that the laravel application uses telegram authentication api to authenticate its users.