Skip to content

Commit cdd3349

Browse files
committed
Social login revisions.
1 parent 7362930 commit cdd3349

File tree

11 files changed

+65
-18
lines changed

11 files changed

+65
-18
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Controllers/AccountController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public ActionResult Login(string userNameOrEmailAddress = "", string returnUrl =
8484
{
8585
ReturnUrl = returnUrl,
8686
IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
87-
IsSelfRegistrationAllowed = IsSelfRegistrationEnabled()
87+
IsSelfRegistrationAllowed = IsSelfRegistrationEnabled(),
88+
MultiTenancySide = AbpSession.MultiTenancySide
8889
});
8990
}
9091

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace AbpCompanyName.AbpProjectName.Web.Models.Account
1+
using Abp.MultiTenancy;
2+
3+
namespace AbpCompanyName.AbpProjectName.Web.Models.Account
24
{
35
public class LoginFormViewModel
46
{
@@ -7,5 +9,7 @@ public class LoginFormViewModel
79
public bool IsMultiTenancyEnabled { get; set; }
810

911
public bool IsSelfRegistrationAllowed { get; set; }
12+
13+
public MultiTenancySides MultiTenancySide { get; set; }
1014
}
1115
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Views/Account/Login.cshtml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@using Abp.Authorization.Users
1+
@using Abp.Extensions
2+
@using Abp.Authorization.Users
3+
@using Abp.MultiTenancy
24
@model AbpCompanyName.AbpProjectName.Web.Models.Account.LoginFormViewModel
35
@section Styles
46
{
@@ -61,5 +63,45 @@
6163
</div>
6264
}
6365
</form>
66+
67+
@{
68+
var loginProviders = Context.Authentication
69+
.GetAuthenticationSchemes()
70+
.Where(s => !s.DisplayName.IsNullOrWhiteSpace())
71+
.ToList();
72+
73+
Func<string, string> getSocialIconClass = (provider) =>
74+
{
75+
provider = provider.ToLowerInvariant();
76+
77+
if (provider == "microsoft")
78+
{
79+
return "windows";
80+
}
81+
82+
return provider;
83+
};
84+
}
85+
86+
@if (Model.MultiTenancySide == MultiTenancySides.Tenant && loginProviders.Count > 0)
87+
{
88+
<div class="login-options">
89+
<h4>@L("OrLoginWith")</h4>
90+
<ul class="social-icons">
91+
<form asp-action="ExternalLogin" method="post">
92+
<input type="hidden" name="returnUrl" value="@ViewBag.ReturnUrl" />
93+
<input type="hidden" name="provider" value="" />
94+
95+
@foreach (var p in loginProviders)
96+
{
97+
<a class="btn btn-default btn-sm fa fa-@(getSocialIconClass(p.DisplayName)) social-login-link" title="@p.DisplayName"
98+
data-provider="@p.DisplayName"
99+
href="javascript:;">
100+
</a>
101+
}
102+
</form>
103+
</ul>
104+
</div>
105+
}
64106
</div>
65107
</div>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/appsettings.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313
"ClientId": "",
1414
"ClientSecret": ""
1515
},
16-
"Twitter": {
17-
"IsEnabled": "false",
18-
"ConsumerKey": "",
19-
"ConsumerSecret": ""
20-
},
21-
"Microsoft": {
22-
"IsEnabled": "false",
23-
"ConsumerKey": "",
24-
"ConsumerSecret": ""
25-
},
2616
"JwtBearer": {
2717
"IsEnabled": "true",
2818
"SecurityKey": "AbpProjectName_C421AAEE0D114E9C",

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Account/Login.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
}
55
.social-icons {
66
padding-left: 0px;
7+
}
8+
.social-icons a.btn-sm {
9+
margin-right: 5px;
710
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Account/Login.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@
55

66
.social-icons {
77
padding-left: 0px;
8+
9+
a.btn-sm {
10+
margin-right: 5px;
11+
}
812
}
13+

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Account/Login.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Shared/Components/TenantChange/Default.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
(function () {
2-
32
$('.tenant-change-component a')
43
.click(function (e) {
54
e.preventDefault();
@@ -13,5 +12,4 @@
1312
error: function (e) { }
1413
});
1514
});
16-
1715
})();

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Shared/Components/TenantChange/Default.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Shared/Components/TenantChange/_ChangeModal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@
5151
});
5252

5353
$.AdminBSB.input.activate(_$form);
54+
55+
$('#TenantChangeModal').on('shown.bs.modal', function () {
56+
_$form.find('input[type=text]:first').focus();
57+
});
5458
})(jQuery);

0 commit comments

Comments
 (0)