-
Notifications
You must be signed in to change notification settings - Fork 60
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
UnauthorizedError ! #71
Comments
I tried to set |
I'll check and get back to you |
Thanks in advance. I'm not sure if this related, but I preferred to report it just to take in the consideration.
|
I tried to update the packages using
|
@mbnoimi I'll try to upgrade this starter kit to latest LB4 versions over this weekend. Or, if you want to contribute, it will be just fine. But seems like you are facing issues. Let me know. |
I just merged one PR -> #65 which upgrades some of the LB4 deps. Can you please check now ? |
Now, I'm able to see a more detailed error message as following: {
"error": {
"statusCode": 401,
"name": "UnauthorizedError",
"message": {
"length": 177,
"name": "error",
"severity": "ERROR",
"code": "42703",
"hint": "Perhaps you meant to reference the column \"auth_clients.deleted\".",
"position": "18",
"file": "parse_relation.c",
"line": "3504",
"routine": "errorMissingColumn"
}
}
} But to be accurate. You didn't update the project to recent packages because I'm still see a differences: |
Yes I didn't. This was an old PR from another contributor which I merged. |
Now this error means we are trying to reference a non existing column. Can you show me your auth-client.model.ts ? |
import {model, property} from '@loopback/repository';
import {IAuthClient} from 'loopback4-authentication';
import {BaseEntity} from './base-entity.model';
@model({
name: 'auth_clients',
})
export class AuthClient extends BaseEntity implements IAuthClient {
@property({
type: 'number',
id: true,
})
id?: number;
@property({
type: 'string',
required: true,
name: 'client_id',
})
clientId: string;
@property({
type: 'string',
required: true,
name: 'client_secret',
})
clientSecret: string;
@property({
type: 'string',
required: true,
})
secret: string;
@property({
type: 'string',
name: 'redirect_url',
})
redirectUrl?: string;
@property({
type: 'array',
itemType: 'number',
name: 'user_ids',
})
userIds: number[];
@property({
type: 'number',
required: true,
name: 'access_token_expiration',
})
accessTokenExpiration: number;
@property({
type: 'number',
required: true,
name: 'refresh_token_expiration',
})
refreshTokenExpiration: number;
@property({
type: 'number',
required: true,
name: 'auth_code_expiration',
})
authCodeExpiration: number;
constructor(data?: Partial<AuthClient>) {
super(data);
}
} |
Ah ! Got it. There has been a major upgrade of soft-delete package here. With that upgrade, you need to add 2 new columns to all tables where you are inheriting from BaseEntity or SoftDeleteEntity class. Columns are deleted_on, deleted_by. Refer to this -> https://github.com/sourcefuse/loopback4-soft-delete/blob/v3.0.0/src/models/soft-delete-entity.ts Also this changelog -> https://github.com/sourcefuse/loopback4-soft-delete/releases/tag/v3.0.0 |
Oops, I'll try to do it manually, but I believe it's time to use LB ORM instead of using |
Do I've to modify the tables and models too? |
ORM is loopback-juggler only. I just dont use Loopback migrations as they are not reliable. Read the warning here -> https://loopback.io/doc/en/lb4/Database-migrations.html |
No need to update models. Just the tables in DB. |
Do I've to modify 20190430110622-init-script-up.sql to for the future setups? |
BTW, I opened a feature request loopbackio/loopback-next#7119 for adding templates in LB |
Yeah. If you can raise a PR for this, it will be a great help. Or, you can generate a new migration script adding these columns using alter script. Raise a PR, I can review and merge. |
Great to hear. I'll upvote it. |
/auth/login {
"client_id": "webapp",
"client_secret": "saqw21!@",
"username": "super_admin",
"password": "test123!@#"
} Response: {
"code": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IndlYmFwcCIsInVzZXJJZCI6MSwiaWF0IjoxNjE0NDI0MjQ2LCJleHAiOjE2MTQ0MjQ0MjYsImF1ZCI6IndlYmFwcCIsImlzcyI6ImxiX2FwaSIsInN1YiI6InN1cGVyX2FkbWluIn0.KnEHLa5BZIga6TyogUEm8S4BqYgJGlyi2XiC4Bl8Pqk"
} /auth/token {
"code": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IndlYmFwcCIsInVzZXJJZCI6MSwiaWF0IjoxNjE0NDI0MjQ2LCJleHAiOjE2MTQ0MjQ0MjYsImF1ZCI6IndlYmFwcCIsImlzcyI6ImxiX2FwaSIsInN1YiI6InN1cGVyX2FkbWluIn0.KnEHLa5BZIga6TyogUEm8S4BqYgJGlyi2XiC4Bl8Pqk",
"clientId": "webapp",
"username": "super_admin"
} Response: {
"error": {
"statusCode": 401,
"name": "UnauthorizedError",
"message": "Invalid Credentials"
}
} |
Logs ? Can you debug inside the login.controller.ts ? |
I don't know how to debug (I'm still a newbie in LB) but the terminal doesn't show any error, so I tried to enable logging depending on LB instructions, but I get this error:
|
I'll check it then. Basically you debug using vs code |
I run |
@samarpan-b Looks like it has something to do with #2639 |
@mbnoimi @kevinjasti can u guys check with the latest now ? |
@mbnoimi @kevinjasti can you confirm if it is okay to close this issue? |
Closing it for now. |
I had this error after cloning latest repo and updating dependencies - the soft delete package required the following to be added to most if not all existing tables in the SQL files
I don't understand the internals enough to do a PR, just putting this up here for anyone who encounters the issue. |
Thanks @rlyttle . Thats a new breaking change in soft delete package. Refer this - sourcefuse/loopback4-soft-delete#14 |
@samarpan-b thanks. Is there not a need to re-open this bug and issue a PR with updated SQL files? |
I think it was optional. If not, then yes. Can you raise a new issue to evaluate and put a fix to it @rlyttle ? |
Whenever I call
/auth/login-token
or/auth/login
I get the following response:Request:
Response:
.env:
DB structure:
More info:
NOTE: I tried to use both options
JWT_SECRET=plmnkoxswqaz
&JWT_SECRET=plmnkoqazxsw
, but I always get the same result.The text was updated successfully, but these errors were encountered: