With SimpleMembership you can add an icon to the external authentication provider buttons like this:
SimpleMembership:
Dictionary<string, object> FacebooksocialData = new Dictionary<string, object>();
FacebooksocialData.Add("Icon", "/content/images/gui/loginFacebook.png");
OAuthWebSecurity.RegisterFacebookClient(
appId: "x",
appSecret: "x",
displayName: "Facebook",
extraData: FacebooksocialData);
And then display them like this in your view:
@foreach (AuthenticationClientData p in Model)
{
<button class="externalLoginService" style="cursor:pointer;color:transparent;border:none;background:url(@p.ExtraData["Icon"]);width:94px;height:93px;margin-right:20px;" type="submit" name="provider" value="@p.AuthenticationClient.ProviderName" title="Log in with @p.DisplayName">@p.DisplayName</button>
}
ASP.NET Identity(?):
app.UseFacebookAuthentication(
appId: "x",
appSecret: "x");
How to achieve the same thing using ASP.NET Identity (controller and view)?
Another way of doing it:
Took some of what is in this blog (uses zocial icons but I found those to be overkill - see css file and you'll know what I mean): http://www.beabigrockstar.com/pretty-social-login-buttons-for-asp-net-mvc-5/
And did it like this:
Startup.Auth.cs
(no extra nothing, just the standard default stuff from an MVC 5 app)
app.UseFacebookAuthentication(appId: "x", appSecret: "x");
app.UseGoogleAuthentication();
CSS:
.socialLoginButton {
cursor:pointer;color:transparent;border:none;width:94px;height:93px;margin-right:20px;
}
.socialLoginButton.facebook {
background:url(/content/images/gui/loginFacebook.png);
}
.socialLoginButton.google {
background:url(/content/images/gui/loginGoogle.png);
}
View:
<button type="submit" class="externalLoginService socialLoginButton @p.AuthenticationType.ToLower()" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in with @p.Caption">@p.AuthenticationType</button>
Using classes instead of the not so elegant style attribute in the other solution/answer above.
You can still do something similar, basically in Startup.Auth.cs you will need to add extra data to the AuthenticationDescription when you enable the auth provider:
var desc = new AuthenticationDescription();
desc.Caption = "Google";
desc.AuthenticationType = "Google";
desc.Properties["Img"] = "<img>";
app.UseGoogleAuthentication(new GoogleAuthenticationOptions() { Description = desc });
And then use the @p.Properties["Img"] in your button like you were doing before inside of the _ExternalLoginListPartial view
<legend>Use another service to log in.</legend>
<p>
@foreach (AuthenticationDescription p in loginProviders) {
<button type="submit" class="btn" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">@p.AuthenticationType</button>
}
</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With