Update names of collab auth functions to clarify behavior (#32648)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-12 18:35:18 -06:00 committed by GitHub
parent cef0c415f6
commit 1078f929aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 23 additions and 16 deletions

View file

@ -97,7 +97,7 @@ impl std::fmt::Display for SystemIdHeader {
pub fn routes(rpc_server: Arc<rpc::Server>) -> Router<(), Body> {
Router::new()
.route("/user", get(get_authenticated_user))
.route("/user", get(update_or_create_authenticated_user))
.route("/users/look_up", get(look_up_user))
.route("/users/:id/access_tokens", post(create_access_token))
.route("/rpc_server_snapshot", get(get_rpc_server_snapshot))
@ -157,7 +157,7 @@ struct AuthenticatedUserResponse {
feature_flags: Vec<String>,
}
async fn get_authenticated_user(
async fn update_or_create_authenticated_user(
Query(params): Query<AuthenticatedUserParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<AuthenticatedUserResponse>> {
@ -165,7 +165,7 @@ async fn get_authenticated_user(
let user = app
.db
.get_or_create_user_by_github_account(
.update_or_create_user_by_github_account(
&params.github_login,
params.github_user_id,
params.github_email.as_deref(),

View file

@ -71,7 +71,7 @@ impl Database {
) -> Result<()> {
self.weak_transaction(|tx| async move {
let user = self
.get_or_create_user_by_github_account_tx(
.update_or_create_user_by_github_account_tx(
github_login,
github_user_id,
github_email,

View file

@ -111,7 +111,7 @@ impl Database {
.await
}
pub async fn get_or_create_user_by_github_account(
pub async fn update_or_create_user_by_github_account(
&self,
github_login: &str,
github_user_id: i32,
@ -121,7 +121,7 @@ impl Database {
initial_channel_id: Option<ChannelId>,
) -> Result<User> {
self.transaction(|tx| async move {
self.get_or_create_user_by_github_account_tx(
self.update_or_create_user_by_github_account_tx(
github_login,
github_user_id,
github_email,
@ -135,7 +135,7 @@ impl Database {
.await
}
pub async fn get_or_create_user_by_github_account_tx(
pub async fn update_or_create_user_by_github_account_tx(
&self,
github_login: &str,
github_user_id: i32,

View file

@ -72,12 +72,12 @@ async fn test_get_users(db: &Arc<Database>) {
}
test_both_dbs!(
test_get_or_create_user_by_github_account,
test_get_or_create_user_by_github_account_postgres,
test_get_or_create_user_by_github_account_sqlite
test_update_or_create_user_by_github_account,
test_update_or_create_user_by_github_account_postgres,
test_update_or_create_user_by_github_account_sqlite
);
async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
async fn test_update_or_create_user_by_github_account(db: &Arc<Database>) {
db.create_user(
"user1@example.com",
None,
@ -104,7 +104,14 @@ async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
.user_id;
let user = db
.get_or_create_user_by_github_account("the-new-login2", 102, None, None, Utc::now(), None)
.update_or_create_user_by_github_account(
"the-new-login2",
102,
None,
None,
Utc::now(),
None,
)
.await
.unwrap();
assert_eq!(user.id, user_id2);
@ -112,7 +119,7 @@ async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
assert_eq!(user.github_user_id, 102);
let user = db
.get_or_create_user_by_github_account(
.update_or_create_user_by_github_account(
"login3",
103,
Some("user3@example.com"),

View file

@ -127,7 +127,7 @@ pub async fn seed(config: &Config, db: &Database, force: bool) -> anyhow::Result
log::info!("Seeding {:?} from GitHub", github_user.login);
let user = db
.get_or_create_user_by_github_account(
.update_or_create_user_by_github_account(
&github_user.login,
github_user.id,
github_user.email.as_deref(),

View file

@ -180,7 +180,7 @@ async fn test_channel_requires_zed_cla(cx_a: &mut TestAppContext, cx_b: &mut Tes
server
.app_state
.db
.get_or_create_user_by_github_account("user_b", 100, None, None, Utc::now(), None)
.update_or_create_user_by_github_account("user_b", 100, None, None, Utc::now(), None)
.await
.unwrap();

View file

@ -82,7 +82,7 @@ impl UserBackfiller {
{
Ok(github_user) => {
self.db
.get_or_create_user_by_github_account(
.update_or_create_user_by_github_account(
&user.github_login,
github_user.id,
user.email_address.as_deref(),