From e91dee5632c87e4d5298a660db828ab555761d9e Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Mon, 26 Aug 2024 11:59:35 +0800 Subject: [PATCH 1/7] chore: update gotrue version --- docker/gotrue.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/gotrue.Dockerfile b/docker/gotrue.Dockerfile index 4831b37f..10aa1b78 100644 --- a/docker/gotrue.Dockerfile +++ b/docker/gotrue.Dockerfile @@ -1,6 +1,6 @@ FROM golang as base WORKDIR /go/src/supabase -RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.117.0 +RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.159.0 WORKDIR /go/src/supabase/gotrue COPY docker/gotrue.patch . RUN git apply gotrue.patch From 0bc92bb739a0e07f213fd4b8bb79c53d5e31c83c Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Mon, 26 Aug 2024 12:10:57 +0800 Subject: [PATCH 2/7] chore: update gotrue version for ci and dev --- docker-compose-ci.yml | 5 +---- docker-compose-dev.yml | 5 +---- docker/gotrue.Dockerfile | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml index 4a684b7b..dc4afc2b 100644 --- a/docker-compose-ci.yml +++ b/docker-compose-ci.yml @@ -50,10 +50,7 @@ services: gotrue: restart: on-failure - build: - context: . - dockerfile: docker/gotrue.Dockerfile - image: appflowyinc/gotrue:${GOTRUE_VERSION:-latest} + image: supabase/gotrue:v2.159.1 environment: # There are a lot of options to configure GoTrue. You can reference the example config: # https://github.com/supabase/gotrue/blob/master/example.env diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 68c98e80..98da16c8 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -45,10 +45,7 @@ services: gotrue: restart: on-failure - build: - context: . - dockerfile: docker/gotrue.Dockerfile - image: appflowyinc/gotrue:${GOTRUE_VERSION:-latest} + image: supabase/gotrue:v2.159.1 depends_on: - postgres environment: diff --git a/docker/gotrue.Dockerfile b/docker/gotrue.Dockerfile index 10aa1b78..4831b37f 100644 --- a/docker/gotrue.Dockerfile +++ b/docker/gotrue.Dockerfile @@ -1,6 +1,6 @@ FROM golang as base WORKDIR /go/src/supabase -RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.159.0 +RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.117.0 WORKDIR /go/src/supabase/gotrue COPY docker/gotrue.patch . RUN git apply gotrue.patch From eb74e095b508174ac711b7de0494ba429f5a1e72 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 27 Aug 2024 10:15:20 +0800 Subject: [PATCH 3/7] fix: update for later version of gotrue --- libs/gotrue-entity/src/dto.rs | 2 +- libs/gotrue/src/api.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/gotrue-entity/src/dto.rs b/libs/gotrue-entity/src/dto.rs index 707ff264..9274f35d 100644 --- a/libs/gotrue-entity/src/dto.rs +++ b/libs/gotrue-entity/src/dto.rs @@ -105,7 +105,7 @@ pub struct GoTrueSettings { pub mailer_autoconfirm: bool, pub phone_autoconfirm: bool, pub sms_provider: String, - pub mfa_enabled: bool, + pub mfa_enabled: Option, // later version have this field removed pub saml_enabled: bool, } diff --git a/libs/gotrue/src/api.rs b/libs/gotrue/src/api.rs index d7d487a5..cfd77fbb 100644 --- a/libs/gotrue/src/api.rs +++ b/libs/gotrue/src/api.rs @@ -48,9 +48,7 @@ impl Client { pub async fn settings(&self) -> Result { let url: String = format!("{}/settings", self.base_url); let resp = self.client.get(&url).send().await?; - let settings: GoTrueSettings = from_response(resp) - .await - .context(format!("calling {} failed", url))?; + let settings: GoTrueSettings = from_response(resp).await?; Ok(settings) } From 0c9b5882abca7b70d817f99d54d331ac3f6490b6 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 27 Aug 2024 10:53:23 +0800 Subject: [PATCH 4/7] chore: better display in tests --- tests/user/sign_in.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/user/sign_in.rs b/tests/user/sign_in.rs index ffb749c1..d391093d 100644 --- a/tests/user/sign_in.rs +++ b/tests/user/sign_in.rs @@ -7,7 +7,7 @@ async fn sign_in_unknown_user() { let password = "Hello123!"; let c = localhost_client(); let err = c.sign_in_password(&email, password).await.unwrap_err(); - assert_eq!(err.code, ErrorCode::OAuthError); + assert_eq!(err.code, ErrorCode::OAuthError, "{:?}", err); assert!(!err.message.is_empty()); } @@ -24,7 +24,7 @@ async fn sign_in_wrong_password() { .sign_in_password(&email, wrong_password) .await .unwrap_err(); - assert_eq!(err.code, ErrorCode::OAuthError); + assert_eq!(err.code, ErrorCode::OAuthError, "{:?}", err); assert!(!err.message.is_empty()); } @@ -37,7 +37,7 @@ async fn sign_in_unconfirmed_email() { c.sign_up(&email, password).await.unwrap(); let err = c.sign_in_password(&email, password).await.unwrap_err(); - assert_eq!(err.code, ErrorCode::OAuthError); + assert_eq!(err.code, ErrorCode::OAuthError, "{:?}", err); assert!(!err.message.is_empty()); } @@ -88,7 +88,7 @@ async fn sign_in_with_invalid_url() { let c = localhost_client(); match c.sign_in_with_url(url_str).await { Ok(_) => panic!("should not be ok"), - Err(e) => assert_eq!(e.code, ErrorCode::OAuthError), + Err(e) => assert_eq!(e.code, ErrorCode::OAuthError, "{:?}", e), } } From 96e1463b396b5f2c26363a230874b542be8b56e3 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 27 Aug 2024 11:36:51 +0800 Subject: [PATCH 5/7] fix: compatibility error --- libs/app-error/src/gotrue.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/app-error/src/gotrue.rs b/libs/app-error/src/gotrue.rs index 16099556..3713ce25 100644 --- a/libs/app-error/src/gotrue.rs +++ b/libs/app-error/src/gotrue.rs @@ -85,15 +85,16 @@ impl Display for GoTrueErrorSerde { /// Used to deserialize the response from the gotrue server #[derive(Serialize, Deserialize, Debug, Error)] pub struct GotrueClientError { - pub error: String, + pub error: Option, pub error_description: Option, + pub msg: Option, } impl Display for GotrueClientError { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( - "error: {}, description: {:?}", - self.error, self.error_description + "error: {:?}, error_description: {:?}, msg: {:?}", + self.error, self.error_description, self.msg )) } } From 8d9e119f7021efc0ff0d81aabd853a5d822dc106 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 27 Aug 2024 12:09:42 +0800 Subject: [PATCH 6/7] fix: version update compatibility --- tests/user/sign_up.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/user/sign_up.rs b/tests/user/sign_up.rs index 8a683a94..b20cf73f 100644 --- a/tests/user/sign_up.rs +++ b/tests/user/sign_up.rs @@ -19,7 +19,7 @@ async fn sign_up_invalid_email() { .sign_up(invalid_email, password) .await .unwrap_err(); - assert_eq!(error.code, ErrorCode::InvalidRequest); + assert_eq!(error.code, ErrorCode::OAuthError); assert_eq!( error.message, "Invalid request:Unable to validate email address: invalid format" @@ -35,7 +35,7 @@ async fn sign_up_invalid_password() { assert_eq!(error.code, ErrorCode::InvalidRequest); assert_eq!( error.message, - "Invalid request:Password should be at least 6 characters" + "Invalid request:Password should be at least 6 characters." ); } From e7236c115d90a5f55d16fe7ce97e411a4ef5f26f Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 27 Aug 2024 12:55:10 +0800 Subject: [PATCH 7/7] fix: version update compatibility --- tests/user/sign_up.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/user/sign_up.rs b/tests/user/sign_up.rs index b20cf73f..e580806f 100644 --- a/tests/user/sign_up.rs +++ b/tests/user/sign_up.rs @@ -22,7 +22,7 @@ async fn sign_up_invalid_email() { assert_eq!(error.code, ErrorCode::OAuthError); assert_eq!( error.message, - "Invalid request:Unable to validate email address: invalid format" + "Unable to validate email address: invalid format" ); }