mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-15 20:23:50 +08:00
feat: support MetaMask provider (#2084)
* feat: add metamask provider * feat: add eth login * feat: check eth sign * feat: finish metamask signin/signup * feat: support MetaMask provider link/unlink * feat: update web/craco.config.js to handle polyfill * feat: gofumpt idp/metamask.go * feat: update MetaMask logo path * feat: support MetaMask avatar
This commit is contained in:
@ -17,6 +17,7 @@ import i18next from "i18next";
|
||||
import * as Provider from "./Provider";
|
||||
import {getProviderLogoURL} from "../Setting";
|
||||
import {GithubLoginButton, GoogleLoginButton} from "react-social-login-buttons";
|
||||
import {authViaMetaMask} from "./Web3Auth";
|
||||
import QqLoginButton from "./QqLoginButton";
|
||||
import FacebookLoginButton from "./FacebookLoginButton";
|
||||
import WeiboLoginButton from "./WeiboLoginButton";
|
||||
@ -117,6 +118,12 @@ function goToSamlUrl(provider, location) {
|
||||
});
|
||||
}
|
||||
|
||||
export function goToWeb3Url(application, provider, method) {
|
||||
if (provider.type === "MetaMask") {
|
||||
authViaMetaMask(application, provider, method);
|
||||
}
|
||||
}
|
||||
|
||||
export function renderProviderLogo(provider, application, width, margin, size, location) {
|
||||
if (size === "small") {
|
||||
if (provider.category === "OAuth") {
|
||||
@ -153,6 +160,12 @@ export function renderProviderLogo(provider, application, width, margin, size, l
|
||||
<img width={width} height={width} src={getProviderLogoURL(provider)} alt={provider.displayName} style={{margin: margin}} />
|
||||
</a>
|
||||
);
|
||||
} else if (provider.category === "Web3") {
|
||||
return (
|
||||
<a key={provider.displayName} onClick={() => goToWeb3Url(application, provider, "signup")}>
|
||||
<img width={width} height={width} src={getProviderLogoURL(provider)} alt={provider.displayName} style={{margin: margin}} />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
} else if (provider.type === "Custom") {
|
||||
// style definition
|
||||
@ -192,6 +205,16 @@ export function renderProviderLogo(provider, application, width, margin, size, l
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
} else if (provider.category === "Web3") {
|
||||
return (
|
||||
<div key={provider.displayName} style={{marginBottom: "10px"}}>
|
||||
<a onClick={() => goToWeb3Url(application, provider, "signup")}>
|
||||
{
|
||||
getSigninButton(provider)
|
||||
}
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div key={provider.displayName} style={{marginBottom: "10px"}}>
|
||||
|
Reference in New Issue
Block a user