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

login auth/login #54

Closed
personwholearn opened this issue Jul 18, 2020 · 14 comments
Closed

login auth/login #54

personwholearn opened this issue Jul 18, 2020 · 14 comments

Comments

@personwholearn
Copy link

when I go to http://127.0.0.1:3000/auth/login and send the request with the below

{
"client_id": "webapp",
"client_secret": "saqw21!@",
"username": "super_admin",
"password": "test123!@#"
}

I got reponed of

{
"error": {
"statusCode": 401,
"name": "UnauthorizedError",
"message": {
"name": "error",
"length": 185,
"severity": "ERROR",
"code": "42P01",
"position": "194",
"file": "d:\pginstaller_12.auto\postgres.windows-x64\src\backend\parser\parse_relation.c",
"line": "1173",
"routine": "parserOpenTable"
}
}
}

@mayank-SFIN571
Copy link

Hi @personwholearn
Can you share the .env file and the database structure. I just want to confirm whether the setup for the application is complete.

I am asking this because the error you are facing is when some table that you are trying to query to is not present in the database.

For reference you can check this

@personwholearn
Copy link
Author

personwholearn commented Jul 24, 2020

hi @mayank-SFIN571 ,this my .env file details :
NODE_ENV=
LOG_LEVEL=
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=123
DB_DATABASE=postgres
DB_SCHEMA=postgres
REDIS_HOST=
REDIS_PORT=
REDIS_URL=
REDIS_PASSWORD=
REDIS_DATABASE=0
JWT_SECRET=
JWT_ISSUER=
AUDIT_SCHEMA=
USER_TEMP_PASSWORD=
GOOGLE_AUTH_URL=
GOOGLE_AUTH_CLIENT_ID=
GOOGLE_AUTH_CLIENT_SECRET=
GOOGLE_AUTH_TOKEN_URL=
GOOGLE_AUTH_CALLBACK_URL=

@personwholearn
Copy link
Author

personwholearn commented Jul 24, 2020

in some other test project

DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=123
DB_DATABASE=todolist3
DB_SCHEMA=todolist3
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=
REDIS_PASSWORD=
REDIS_DATABASE=0
then i do db-migrate up

@personwholearn
Copy link
Author

hello @mayank-SFIN571 , can you help me ?

@mayank-SFIN571
Copy link

mayank-SFIN571 commented Jul 31, 2020

hello @personwholearn
Totally missed the email for this thread.

Can you check whether your migrations were successful or not. The only reason I am focusing on the Database structure is because the error is for "tableName does not exist" according to the postgresql docs.

Also to ensure everything is in place, i cloned the repo and tried with this .env

NODE_ENV=production
LOG_LEVEL=info
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgrestest
DB_DATABASE=lbstarter
DB_SCHEMA=
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=
REDIS_PASSWORD=
REDIS_DATABASE=0
JWT_SECRET=plmnkoxswqaz
JWT_ISSUER=lb_api
AUDIT_SCHEMA=logs
USER_TEMP_PASSWORD=temp123!@#
DEFAULT_ROLE=super_admin

This configuration is working fine for me.

Also do check whether your Database structure look like this

image

In your case the name of the Database should be postgres and the schema name should again be postgres

@mayank-SFIN571
Copy link

mayank-SFIN571 commented Jul 31, 2020

@personwholearn
A wild guess, In migrations the schema that holds the user information is configured to be lbstarter (unless you modify the migrations), so keeping DB_SCHEMA=postgres will tell juggler to connect to schema postgres. But in actual scenario the schema is lbstarter. Please make sure we are having the right schema in the environment.

@personwholearn
Copy link
Author

personwholearn commented Jul 31, 2020

i will test your .env and give you feedback>>>

NODE_ENV=production
LOG_LEVEL=info
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgrestest
DB_DATABASE=lbstarter
DB_SCHEMA=
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=
REDIS_PASSWORD=
REDIS_DATABASE=0
JWT_SECRET=plmnkoxswqaz
JWT_ISSUER=lb_api
AUDIT_SCHEMA=logs
USER_TEMP_PASSWORD=temp123!@#
DEFAULT_ROLE=super_admin

@mayank-SFIN571

@mayank-SFIN571
Copy link

@personwholearn just make sure you have the correct schema name in you .env file.

@personwholearn
Copy link
Author

i will test it with schema of lbstarter and without schema

@personwholearn
Copy link
Author

thanks bro so much it works

NODE_ENV=production
LOG_LEVEL=info
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=123
DB_DATABASE=lbstarter
DB_SCHEMA=lbstarter
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=
REDIS_PASSWORD=
REDIS_DATABASE=0
JWT_SECRET=plmnkoxswqaz
JWT_ISSUER=lb_api
AUDIT_SCHEMA=logs
USER_TEMP_PASSWORD=temp123!@#
DEFAULT_ROLE=super_admin

@mayank-SFIN571 what is different between /auth/token and /auth/login-token and how can i login through postman or saving the access token for every requeset?

@mayank-SFIN571
Copy link

mayank-SFIN571 commented Jul 31, 2020

Hi @personwholearn
auth/token is actually a part of oauth. To correctly understand it please refer to this tutorial.

Whereas /auth/login-token is a Resource owner technique, which is again explained in the above mention tutorial.

You can work with any of the above methods, according to your application needs.

@personwholearn
Copy link
Author

ok thanks soooooo much i also followed
https://stackoverflow.com/questions/55524597/loopback-4-add-authorize-button-in-api-explorer

for Adding 'Authorize' button in API explorer and it works .

@personwholearn
Copy link
Author

personwholearn commented Jul 31, 2020

@mayank-SFIN571 can I change the password of "temp123!@#" of the new user through API

@personwholearn
Copy link
Author

@mayank-SFIN571 which controller can I change the password ? or do I have to create a new one?

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

2 participants