mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Can get current user ID
This commit is contained in:
		@@ -34,7 +34,7 @@ pub fn login_user(email: &str, password: &str, client: &APIClient) -> ResultBoxE
 | 
			
		||||
    let new_token = UserAccessToken {
 | 
			
		||||
        user_id: user.id,
 | 
			
		||||
        client_id: client.id,
 | 
			
		||||
        token: rand_str(150)
 | 
			
		||||
        token: rand_str(150),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // Save it
 | 
			
		||||
@@ -63,4 +63,14 @@ fn get_client_tokens(user_id: UserID, client: &APIClient) -> ResultBoxError<User
 | 
			
		||||
            })
 | 
			
		||||
        },
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Find a user ID based on login token
 | 
			
		||||
pub fn get_user_by_login_token(token: &str, client: &APIClient) -> ResultBoxError<UserID> {
 | 
			
		||||
    database::query_row(
 | 
			
		||||
        QueryInfo::new(USER_ACCESS_TOKENS_TABLE)
 | 
			
		||||
            .cond_u32("service_id", client.id)
 | 
			
		||||
            .cond("token1", token),
 | 
			
		||||
        |res| res.get_int64("user_id"),
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user