Skip to content

Commit b9bf53f

Browse files
committed
add initial
1 parent 48f3a92 commit b9bf53f

File tree

828 files changed

+1024011
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

828 files changed

+1024011
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ package-lock
3737
.DS_Store
3838
Thumbs.db
3939

40+
# VS Code Files files
41+
.vscode/
42+
43+
4044
# VS files
4145
project.lock.json
4246
Properties/launchSettings.json
@@ -53,3 +57,4 @@ src/assets/metronic/themes/**/css/*.min.css
5357
src/assets/fonts/*min.css
5458

5559
src/assets/metronic/themes/default/css/skins/**/*.min.css
60+
package-lock.json

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
network-timeout 600000

Controllers/AntiForgeryController.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Antiforgery;
2+
3+
namespace ThemeTestingProjectDemo.Web.Controllers
4+
{
5+
public class AntiForgeryController : ThemeTestingProjectDemoControllerBase
6+
{
7+
private readonly IAntiforgery _antiforgery;
8+
9+
public AntiForgeryController(IAntiforgery antiforgery)
10+
{
11+
_antiforgery = antiforgery;
12+
}
13+
14+
public void GetToken()
15+
{
16+
_antiforgery.SetCookieTokenAndHeader(HttpContext);
17+
}
18+
}
19+
}

Controllers/ChatController.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Net;
3+
using System.Threading.Tasks;
4+
using Abp.AspNetCore.Mvc.Authorization;
5+
using Microsoft.AspNetCore.Mvc;
6+
using ThemeTestingProjectDemo.Chat;
7+
using ThemeTestingProjectDemo.Storage;
8+
9+
namespace ThemeTestingProjectDemo.Web.Controllers
10+
{
11+
[AbpMvcAuthorize]
12+
public class ChatController : ChatControllerBase
13+
{
14+
public ChatController(IBinaryObjectManager binaryObjectManager, IChatMessageManager chatMessageManager) :
15+
base(binaryObjectManager, chatMessageManager)
16+
{
17+
}
18+
19+
public async Task<ActionResult> GetUploadedObject(Guid fileId, string fileName, string contentType)
20+
{
21+
using (CurrentUnitOfWork.SetTenantId(null))
22+
{
23+
var fileObject = await BinaryObjectManager.GetOrNullAsync(fileId);
24+
if (fileObject == null)
25+
{
26+
return StatusCode((int)HttpStatusCode.NotFound);
27+
}
28+
29+
return File(fileObject.Bytes, contentType, fileName);
30+
}
31+
}
32+
}
33+
}

Controllers/ConsentController.cs

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using IdentityServer4;
5+
using IdentityServer4.Models;
6+
using IdentityServer4.Services;
7+
using IdentityServer4.Stores;
8+
using Microsoft.AspNetCore.Mvc;
9+
using ThemeTestingProjectDemo.Web.Controllers;
10+
using ThemeTestingProjectDemo.Web.Models.Consent;
11+
12+
namespace ThemeTestingProjectDemo.Web.Host.Controllers
13+
{
14+
public class ConsentController : ThemeTestingProjectDemoControllerBase
15+
{
16+
private readonly IIdentityServerInteractionService _interaction;
17+
private readonly IResourceStore _resourceStore;
18+
private readonly IClientStore _clientStore;
19+
20+
public ConsentController(
21+
IIdentityServerInteractionService interaction,
22+
IClientStore clientStore,
23+
IResourceStore resourceStore
24+
)
25+
{
26+
_interaction = interaction;
27+
_clientStore = clientStore;
28+
_resourceStore = resourceStore;
29+
}
30+
31+
public async Task<IActionResult> Index(string returnUrl)
32+
{
33+
var model = await BuildViewModelAsync(returnUrl);
34+
return View(model);
35+
}
36+
37+
[HttpPost]
38+
[ValidateAntiForgeryToken]
39+
public async Task<IActionResult> Index(ConsentInputModel model)
40+
{
41+
var result = await ProcessConsent(model);
42+
43+
if (result.IsRedirect)
44+
{
45+
return Redirect(result.RedirectUri);
46+
}
47+
48+
if (result.HasValidationError)
49+
{
50+
ModelState.AddModelError("", result.ValidationError);
51+
}
52+
53+
if (result.ShowView)
54+
{
55+
return View("Index", result.ViewModel);
56+
}
57+
58+
throw new Exception("Unexpected model/result!");
59+
}
60+
61+
public async Task<ProcessConsentResult> ProcessConsent(ConsentInputModel model)
62+
{
63+
var result = new ProcessConsentResult();
64+
65+
ConsentResponse grantedConsent = null;
66+
67+
if (model.Button == "no")
68+
{
69+
grantedConsent = ConsentResponse.Denied;
70+
}
71+
else if (model.Button == "yes")
72+
{
73+
if (model.ScopesConsented != null && model.ScopesConsented.Any())
74+
{
75+
var scopes = model.ScopesConsented;
76+
if (ConsentOptions.EnableOfflineAccess == false)
77+
{
78+
scopes = scopes.Where(x => x != IdentityServerConstants.StandardScopes.OfflineAccess);
79+
}
80+
81+
grantedConsent = new ConsentResponse
82+
{
83+
RememberConsent = model.RememberConsent,
84+
ScopesConsented = scopes.ToArray()
85+
};
86+
}
87+
else
88+
{
89+
result.ValidationError = ConsentOptions.MuchChooseOneErrorMessage;
90+
}
91+
}
92+
else
93+
{
94+
result.ValidationError = ConsentOptions.InvalidSelectionErrorMessage;
95+
}
96+
97+
if (grantedConsent != null)
98+
{
99+
var request = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl);
100+
if (request == null)
101+
{
102+
return result;
103+
}
104+
105+
await _interaction.GrantConsentAsync(request, grantedConsent);
106+
107+
result.RedirectUri = model.ReturnUrl;
108+
}
109+
else
110+
{
111+
result.ViewModel = await BuildViewModelAsync(model.ReturnUrl, model);
112+
}
113+
114+
return result;
115+
}
116+
117+
private async Task<ConsentViewModel> BuildViewModelAsync(string returnUrl, ConsentInputModel model = null)
118+
{
119+
var request = await _interaction.GetAuthorizationContextAsync(returnUrl);
120+
if (request == null)
121+
{
122+
return null;
123+
}
124+
125+
var client = await _clientStore.FindEnabledClientByIdAsync(request.ClientId);
126+
if (client == null)
127+
{
128+
return null;
129+
}
130+
131+
var resources = await _resourceStore.FindEnabledResourcesByScopeAsync(request.ScopesRequested);
132+
if (resources != null && (resources.IdentityResources.Any() || resources.ApiResources.Any()))
133+
{
134+
return CreateConsentViewModel(returnUrl, client, resources, model);
135+
}
136+
137+
return null;
138+
}
139+
140+
private ConsentViewModel CreateConsentViewModel(
141+
string returnUrl,
142+
Client client,
143+
Resources resources,
144+
ConsentInputModel model = null)
145+
{
146+
var vm = new ConsentViewModel
147+
{
148+
RememberConsent = model?.RememberConsent ?? true,
149+
ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty<string>(),
150+
ReturnUrl = returnUrl,
151+
ClientName = client.ClientName,
152+
ClientUrl = client.ClientUri,
153+
ClientLogoUrl = client.LogoUri,
154+
AllowRememberConsent = client.AllowRememberConsent
155+
};
156+
157+
vm.IdentityScopes = resources.IdentityResources.Select(x => CreateScopeViewModel(x, vm.ScopesConsented.Contains(x.Name) || model == null)).ToArray();
158+
vm.ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => CreateScopeViewModel(x, vm.ScopesConsented.Contains(x.Name) || model == null)).ToArray();
159+
if (ConsentOptions.EnableOfflineAccess && resources.OfflineAccess)
160+
{
161+
vm.ResourceScopes = vm.ResourceScopes.Union(new [] {
162+
GetOfflineAccessScope(vm.ScopesConsented.Contains(IdentityServerConstants.StandardScopes.OfflineAccess) || model == null)
163+
});
164+
}
165+
166+
return vm;
167+
}
168+
169+
public ScopeViewModel CreateScopeViewModel(IdentityResource identity, bool check)
170+
{
171+
return new ScopeViewModel
172+
{
173+
Name = identity.Name,
174+
DisplayName = identity.DisplayName,
175+
Description = identity.Description,
176+
Emphasize = identity.Emphasize,
177+
Required = identity.Required,
178+
Checked = check || identity.Required,
179+
};
180+
}
181+
182+
public ScopeViewModel CreateScopeViewModel(Scope scope, bool check)
183+
{
184+
return new ScopeViewModel
185+
{
186+
Name = scope.Name,
187+
DisplayName = scope.DisplayName,
188+
Description = scope.Description,
189+
Emphasize = scope.Emphasize,
190+
Required = scope.Required,
191+
Checked = check || scope.Required,
192+
};
193+
}
194+
195+
private ScopeViewModel GetOfflineAccessScope(bool check)
196+
{
197+
return new ScopeViewModel
198+
{
199+
Name = IdentityServerConstants.StandardScopes.OfflineAccess,
200+
DisplayName = ConsentOptions.OfflineAccessDisplayName,
201+
Description = ConsentOptions.OfflineAccessDescription,
202+
Emphasize = true,
203+
Checked = check
204+
};
205+
}
206+
}
207+
}

Controllers/ProfileController.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Abp.AspNetCore.Mvc.Authorization;
2+
using ThemeTestingProjectDemo.Storage;
3+
4+
namespace ThemeTestingProjectDemo.Web.Controllers
5+
{
6+
[AbpMvcAuthorize]
7+
public class ProfileController : ProfileControllerBase
8+
{
9+
public ProfileController(ITempFileCacheManager tempFileCacheManager) :
10+
base(tempFileCacheManager)
11+
{
12+
}
13+
}
14+
}

Controllers/StripeController.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using ThemeTestingProjectDemo.MultiTenancy.Payments.Stripe;
2+
3+
namespace ThemeTestingProjectDemo.Web.Controllers
4+
{
5+
public class StripeController : StripeControllerBase
6+
{
7+
public StripeController(
8+
StripeGatewayManager stripeGatewayManager,
9+
StripePaymentGatewayConfiguration stripeConfiguration,
10+
IStripePaymentAppService stripePaymentAppService)
11+
: base(stripeGatewayManager, stripeConfiguration, stripePaymentAppService)
12+
{
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)