Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not return proper accessToken #13

Open
yuyudhan opened this issue Feb 22, 2016 · 5 comments
Open

Does not return proper accessToken #13

yuyudhan opened this issue Feb 22, 2016 · 5 comments

Comments

@yuyudhan
Copy link

Sqlite3 connector gives following when logging in:
Access token stored in the database is correct, but returned id is the id of accessToken instead of the token itself.

{
  "id": 1,
  "ttl": 1209600,
  "created": "2016-02-22T13:32:31.305Z",
  "userId": 1
}

When using db(in-memory) for storing access tokens it gives following correct result.

{
  "id": "APXMEsHyWmZmXBgi5vAMfWwVfd72nyaXCihskDvqvQILjoliSfGRlcS9MDrtkrrR",
  "ttl": 1209600,
  "created": "2016-02-22T13:33:41.987Z",
  "userId": 1
}
@daschewie
Copy link

Hello yuyudhan,

Did you ever figure this out?

@yuyudhan
Copy link
Author

No @daschewie , did not try this since long, did not find any solution to it.

@vanceeasleaf
Copy link

It seems no body care about this program

@HugoPoi
Copy link

HugoPoi commented May 30, 2018

I investigate this issue in deep.
Sqlite3 has a built-in feature for retrieving the lastID on INSERT statement.
It's use here https://github.com/strongloop-community/loopback-connector-sqlite3/blob/master/lib/sqlite3.js#L202
But in the documentation of Sqlite3 https://sqlite.org/c3ref/last_insert_rowid.html the lastID contains the last rowid inserted but when your primary key is not integer you have two primary key : the primary key define in schema and the sqlite3 internal rowid.
So when we have on INSERT the lastID=an interger and the real id the token which is override by the dao https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L410.

A solution would be to add WITHOUT ROWID option an the CREATE TABLE for the AccessToken and other model with a string primary key.

For that we need to add model options for this connector. I will start to write a PR this afternoon.

EDIT: WITHOUT ROWID does not solve issue because it returns the last ID inserted on all tables.

@HugoPoi
Copy link

HugoPoi commented May 31, 2018

My #38 Solve the issue ;-) You can test my PR in your project

"dependencies": {
  "loopback-connector-sqlite3": "git+https://github.com/HugoPoi/loopback-connector-sqlite3.git#faf96a0"
}

But need a review from the admin team. And a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants