Skip to content

Commit

Permalink
feat: Mock SMS (casdoor#1009)
Browse files Browse the repository at this point in the history
1. Update go-sms-sender to v0.3.0.
2. Fix: avoid page crash if not found provider info.

Signed-off-by: 疯魔慕薇 <[email protected]>

Signed-off-by: 疯魔慕薇 <[email protected]>
  • Loading branch information
kofj authored Aug 17, 2022
1 parent aedef1e commit 91fa024
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/beevik/etree v1.1.0
github.com/casbin/casbin/v2 v2.30.1
github.com/casbin/xorm-adapter/v2 v2.5.1
github.com/casdoor/go-sms-sender v0.2.0
github.com/casdoor/go-sms-sender v0.3.0
github.com/casdoor/goth v1.69.0-FIX2
github.com/casdoor/oss v1.2.0
github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ github.com/casbin/casbin/v2 v2.30.1 h1:P5HWadDL7olwUXNdcuKUBk+x75Y2eitFxYTcLNKeK
github.com/casbin/casbin/v2 v2.30.1/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
github.com/casbin/xorm-adapter/v2 v2.5.1 h1:BkpIxRHKa0s3bSMx173PpuU7oTs+Zw7XmD0BIta0HGM=
github.com/casbin/xorm-adapter/v2 v2.5.1/go.mod h1:AeH4dBKHC9/zYxzdPVHhPDzF8LYLqjDdb767CWJoV54=
github.com/casdoor/go-sms-sender v0.2.0 h1:52bin4EBOPzOee64s9UK7jxd22FODvT9/+Y/Z+PSHpg=
github.com/casdoor/go-sms-sender v0.2.0/go.mod h1:fsZsNnALvFIo+HFcE1U/oCQv4ZT42FdglXKMsEm3WSk=
github.com/casdoor/go-sms-sender v0.3.0 h1:c4bWVcKZhO2L3Xu1oy7aeVkCK6HRJkW/b5K1xU9mV60=
github.com/casdoor/go-sms-sender v0.3.0/go.mod h1:fsZsNnALvFIo+HFcE1U/oCQv4ZT42FdglXKMsEm3WSk=
github.com/casdoor/goth v1.69.0-FIX2 h1:RgfIMkL9kekylgxHHK2ZY8ASAwOGns2HVlaBwLu7Bcs=
github.com/casdoor/goth v1.69.0-FIX2/go.mod h1:Om55nRo8CkeDkPSNBbzXW4G5uI28ZUkSk5S69dPek3s=
github.com/casdoor/oss v1.2.0 h1:ozLAE+nnNdFQBWbzH8U9spzaO8h8NrB57lBcdyMUUQ8=
Expand Down
11 changes: 10 additions & 1 deletion web/src/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export const OtherProviderInfo = {
logo: `${StaticBaseUrl}/img/social_huawei.png`,
url: "https://www.huaweicloud.com/product/msgsms.html",
},
"Mock SMS": {
logo: `${StaticBaseUrl}/img/social_default.png`,
url: "",
},
},
Email: {
"Default": {
Expand Down Expand Up @@ -539,7 +543,12 @@ export function getProviderLogoURL(provider) {
}
return `${StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`;
} else {
return OtherProviderInfo[provider.category][provider.type].logo;
const info = OtherProviderInfo[provider.category][provider.type];
// avoid crash when provider is not found
if (info) {
return info.logo;
}
return "";
}
}

Expand Down
7 changes: 6 additions & 1 deletion web/src/auth/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ export function getProviderUrl(provider) {

return `${urlObj.protocol}//${host}`;
} else {
return Setting.OtherProviderInfo[provider.category][provider.type].url;
const info = Setting.OtherProviderInfo[provider.category][provider.type];
// avoid crash when provider is not found
if (info) {
return info.url;
}
return "";
}
}

Expand Down

0 comments on commit 91fa024

Please sign in to comment.