Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

PersonalAccessTokenCreated is being dispatched twice. #1

Closed
seiferxiii opened this issue May 29, 2021 · 1 comment
Closed

PersonalAccessTokenCreated is being dispatched twice. #1

seiferxiii opened this issue May 29, 2021 · 1 comment

Comments

@seiferxiii
Copy link

I only logged in once, but auth()->user()->logins says i have logged in twice.

Login:

public function login(Request $request){
        $credentials = $request->validate([
            'email' => 'required|email',
            'password' => 'required'
        ]);

        if (!Auth::attempt($credentials)) {
            return $this->error('Credentials not match', 401);
        }

        $personalAccessToken = auth()->user()->createToken('api');
        event(new PersonalAccessTokenCreated($personalAccessToken));

        return $this->success('Login success',
            ['token' => $personalAccessToken->plainTextToken]
        );
    }

Check Logins:

public function logins(){
        $allLoggedInSessions = auth()->user()->logins;
        return $this->success(null,$allLoggedInSessions);
    }

Result:

{
  "status": "Success",
  "message": null,
  "data": [
    {
      "id": 1,
      "created_at": "2021-05-29T14:17:22.000000Z",
      "updated_at": "2021-05-29T14:17:22.000000Z",
      "user_agent": "insomnia\/2021.3.0",
      "ip": "127.0.0.1",
      "ip_data": null,
      "device_type": "",
      "device": " ",
      "platform": "",
      "browser": null,
      "city": null,
      "region": null,
      "country": null,
      "is_current": false
    },
    {
      "id": 2,
      "created_at": "2021-05-29T14:17:22.000000Z",
      "updated_at": "2021-05-29T14:17:22.000000Z",
      "user_agent": "insomnia\/2021.3.0",
      "ip": "127.0.0.1",
      "ip_data": null,
      "device_type": "",
      "device": " ",
      "platform": "",
      "browser": null,
      "city": null,
      "region": null,
      "country": null,
      "is_current": true
    }
  ]
}
@alajusticia
Copy link
Owner

Hi, this package is now discontinued and replaced by a new one that supports Laravel 10 and 11: Laravel Logins

@alajusticia alajusticia closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants