minus-squareplisken@lemmy.fmhy.mltoLemmy@lemmy.ml•How to get `person_id` from currently logged in user in API?linkfedilinkEnglisharrow-up1·edit-21 year agoI haven’t tried, but usually a JWT contains some sort of user ID https://github.com/LemmyNet/lemmy/blob/main/crates/utils/src/claims.rs#L9-L15 pub struct Claims { /// local_user_id, standard claim by RFC 7519. pub sub: i32, pub iss: String, /// Time when this token was issued as UNIX-timestamp in seconds pub iat: i64, } For instance if I decode my current JWT, the payload contains: { "sub": 123, "iss": "lemmy.fmhy.ml", "iat": 1686668459 } sub is the local_user_id If you’re unfamiliar with JWT, check https://jwt.io for a primer and a helpful tool to decode. linkfedilink
I haven’t tried, but usually a JWT contains some sort of user ID
https://github.com/LemmyNet/lemmy/blob/main/crates/utils/src/claims.rs#L9-L15
pub struct Claims { /// local_user_id, standard claim by RFC 7519. pub sub: i32, pub iss: String, /// Time when this token was issued as UNIX-timestamp in seconds pub iat: i64, }
For instance if I decode my current JWT, the payload contains:
{ "sub": 123, "iss": "lemmy.fmhy.ml", "iat": 1686668459 }
sub
is thelocal_user_id
If you’re unfamiliar with JWT, check https://jwt.io for a primer and a helpful tool to decode.