Merge pull request #748 from AppFlowy-IO/gotrue-2.159.0

chore: update gotrue version
This commit is contained in:
Zack 2024-08-27 13:51:24 +08:00 committed by GitHub
commit 612f459a38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 22 deletions

View File

@ -50,10 +50,7 @@ services:
gotrue: gotrue:
restart: on-failure restart: on-failure
build: image: supabase/gotrue:v2.159.1
context: .
dockerfile: docker/gotrue.Dockerfile
image: appflowyinc/gotrue:${GOTRUE_VERSION:-latest}
environment: environment:
# There are a lot of options to configure GoTrue. You can reference the example config: # There are a lot of options to configure GoTrue. You can reference the example config:
# https://github.com/supabase/gotrue/blob/master/example.env # https://github.com/supabase/gotrue/blob/master/example.env

View File

@ -45,10 +45,7 @@ services:
gotrue: gotrue:
restart: on-failure restart: on-failure
build: image: supabase/gotrue:v2.159.1
context: .
dockerfile: docker/gotrue.Dockerfile
image: appflowyinc/gotrue:${GOTRUE_VERSION:-latest}
depends_on: depends_on:
- postgres - postgres
environment: environment:

View File

@ -85,15 +85,16 @@ impl Display for GoTrueErrorSerde {
/// Used to deserialize the response from the gotrue server /// Used to deserialize the response from the gotrue server
#[derive(Serialize, Deserialize, Debug, Error)] #[derive(Serialize, Deserialize, Debug, Error)]
pub struct GotrueClientError { pub struct GotrueClientError {
pub error: String, pub error: Option<String>,
pub error_description: Option<String>, pub error_description: Option<String>,
pub msg: Option<String>,
} }
impl Display for GotrueClientError { impl Display for GotrueClientError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!( f.write_fmt(format_args!(
"error: {}, description: {:?}", "error: {:?}, error_description: {:?}, msg: {:?}",
self.error, self.error_description self.error, self.error_description, self.msg
)) ))
} }
} }

View File

@ -105,7 +105,7 @@ pub struct GoTrueSettings {
pub mailer_autoconfirm: bool, pub mailer_autoconfirm: bool,
pub phone_autoconfirm: bool, pub phone_autoconfirm: bool,
pub sms_provider: String, pub sms_provider: String,
pub mfa_enabled: bool, pub mfa_enabled: Option<bool>, // later version have this field removed
pub saml_enabled: bool, pub saml_enabled: bool,
} }

View File

@ -48,9 +48,7 @@ impl Client {
pub async fn settings(&self) -> Result<GoTrueSettings, GoTrueError> { pub async fn settings(&self) -> Result<GoTrueSettings, GoTrueError> {
let url: String = format!("{}/settings", self.base_url); let url: String = format!("{}/settings", self.base_url);
let resp = self.client.get(&url).send().await?; let resp = self.client.get(&url).send().await?;
let settings: GoTrueSettings = from_response(resp) let settings: GoTrueSettings = from_response(resp).await?;
.await
.context(format!("calling {} failed", url))?;
Ok(settings) Ok(settings)
} }

View File

@ -7,7 +7,7 @@ async fn sign_in_unknown_user() {
let password = "Hello123!"; let password = "Hello123!";
let c = localhost_client(); let c = localhost_client();
let err = c.sign_in_password(&email, password).await.unwrap_err(); 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()); assert!(!err.message.is_empty());
} }
@ -24,7 +24,7 @@ async fn sign_in_wrong_password() {
.sign_in_password(&email, wrong_password) .sign_in_password(&email, wrong_password)
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!(err.code, ErrorCode::OAuthError); assert_eq!(err.code, ErrorCode::OAuthError, "{:?}", err);
assert!(!err.message.is_empty()); assert!(!err.message.is_empty());
} }
@ -37,7 +37,7 @@ async fn sign_in_unconfirmed_email() {
c.sign_up(&email, password).await.unwrap(); c.sign_up(&email, password).await.unwrap();
let err = c.sign_in_password(&email, password).await.unwrap_err(); 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()); assert!(!err.message.is_empty());
} }
@ -88,7 +88,7 @@ async fn sign_in_with_invalid_url() {
let c = localhost_client(); let c = localhost_client();
match c.sign_in_with_url(url_str).await { match c.sign_in_with_url(url_str).await {
Ok(_) => panic!("should not be ok"), Ok(_) => panic!("should not be ok"),
Err(e) => assert_eq!(e.code, ErrorCode::OAuthError), Err(e) => assert_eq!(e.code, ErrorCode::OAuthError, "{:?}", e),
} }
} }

View File

@ -19,10 +19,10 @@ async fn sign_up_invalid_email() {
.sign_up(invalid_email, password) .sign_up(invalid_email, password)
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!(error.code, ErrorCode::InvalidRequest); assert_eq!(error.code, ErrorCode::OAuthError);
assert_eq!( assert_eq!(
error.message, error.message,
"Invalid request:Unable to validate email address: invalid format" "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.code, ErrorCode::InvalidRequest);
assert_eq!( assert_eq!(
error.message, error.message,
"Invalid request:Password should be at least 6 characters" "Invalid request:Password should be at least 6 characters."
); );
} }