MusicStore.Spa fixes:
- Flow app claims to client code properly - Remove unnecessary JS link - Fix JS links on login page
This commit is contained in:
parent
a2e005c017
commit
05237d908e
|
|
@ -70,7 +70,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize("ManageStore", "Allowed")]
|
[Authorize("app-ManageStore", "Allowed")]
|
||||||
public async Task<ActionResult> CreateAlbum()
|
public async Task<ActionResult> CreateAlbum()
|
||||||
{
|
{
|
||||||
var album = new Album();
|
var album = new Album();
|
||||||
|
|
@ -96,7 +96,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{albumId:int}/update")]
|
[HttpPut("{albumId:int}/update")]
|
||||||
[Authorize("ManageStore", "Allowed")]
|
[Authorize("app-ManageStore", "Allowed")]
|
||||||
public async Task<ActionResult> UpdateAlbum(int albumId)
|
public async Task<ActionResult> UpdateAlbum(int albumId)
|
||||||
{
|
{
|
||||||
var album = _storeContext.Albums.SingleOrDefault(a => a.AlbumId == albumId);
|
var album = _storeContext.Albums.SingleOrDefault(a => a.AlbumId == albumId);
|
||||||
|
|
@ -129,7 +129,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{albumId:int}")]
|
[HttpDelete("{albumId:int}")]
|
||||||
[Authorize("ManageStore", "Allowed")]
|
[Authorize("app-ManageStore", "Allowed")]
|
||||||
public async Task<ActionResult> DeleteAlbum(int albumId)
|
public async Task<ActionResult> DeleteAlbum(int albumId)
|
||||||
{
|
{
|
||||||
//var album = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
//var album = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace MusicStore.Spa.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("admin")]
|
[HttpGet("admin")]
|
||||||
[Authorize("ManageStore", "Allowed")]
|
[Authorize("app-ManageStore", "Allowed")]
|
||||||
public IActionResult Admin()
|
public IActionResult Admin()
|
||||||
{
|
{
|
||||||
return View("/Pages/Admin.cshtml");
|
return View("/Pages/Admin.cshtml");
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace MusicStore.Models
|
||||||
user = new ApplicationUser { UserName = settings.DefaultAdminUsername };
|
user = new ApplicationUser { UserName = settings.DefaultAdminUsername };
|
||||||
await userManager.CreateAsync(user, settings.DefaultAdminPassword);
|
await userManager.CreateAsync(user, settings.DefaultAdminPassword);
|
||||||
await userManager.AddToRoleAsync(user, adminRole);
|
await userManager.AddToRoleAsync(user, adminRole);
|
||||||
await userManager.AddClaimAsync(user, new Claim("ManageStore", "Allowed"));
|
await userManager.AddClaimAsync(user, new Claim("app-ManageStore", "Allowed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
<script src="~/lib/angular/angular.js"></script>
|
<script src="~/lib/angular/angular.js"></script>
|
||||||
<script src="~/lib/angular-route/angular-route.js"></script>
|
<script src="~/lib/angular-route/angular-route.js"></script>
|
||||||
<script src="~/lib/angular-bootstrap/ui-bootstrap.js"></script>
|
|
||||||
<script src="~/lib/angular-bootstrap/ui-bootstrap-tpls.js"></script>
|
<script src="~/lib/angular-bootstrap/ui-bootstrap-tpls.js"></script>
|
||||||
@* TODO: This is currently all the compiled TypeScript, non-minified. Need to explore options
|
@* TODO: This is currently all the compiled TypeScript, non-minified. Need to explore options
|
||||||
for alternate loading schemes, e.g. AMD loader of individual modules, min vs. non-min, etc. *@
|
for alternate loading schemes, e.g. AMD loader of individual modules, min vs. non-min, etc. *@
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@
|
||||||
@*@Scripts.Render("~/bundles/jqueryval")*@
|
@*@Scripts.Render("~/bundles/jqueryval")*@
|
||||||
@*<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
|
@*<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
|
||||||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>*@
|
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>*@
|
||||||
<script src="~/js/angular.js"></script>
|
<script src="~/lib/angular/angular.js"></script>
|
||||||
<script src="~/js/angular-route.js"></script>
|
<script src="~/lib/angular-route/angular-route.js"></script>
|
||||||
@* TODO: This is currently all the compiled TypeScript, non-minified. Need to explore options
|
@* TODO: This is currently all the compiled TypeScript, non-minified. Need to explore options
|
||||||
for alternate loading schemes, e.g. AMD loader of individual modules, min vs. non-min, etc. *@
|
for alternate loading schemes, e.g. AMD loader of individual modules, min vs. non-min, etc. *@
|
||||||
<script src="~/js/MusicStore.Store.js"></script>
|
<script src="~/js/MusicStore.Store.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
@using System.Security.Principal
|
@using System.Security.Principal
|
||||||
|
@using System.Security.Claims
|
||||||
@using Microsoft.AspNet.Identity
|
@using Microsoft.AspNet.Identity
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
@ -18,15 +19,18 @@
|
||||||
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@*@Html.Json(new {
|
@Html.Json(new {
|
||||||
isAuthenticated = true,
|
isAuthenticated = true,
|
||||||
userName = User.Identity.GetUserName(),
|
userName = User.Identity.GetUserName(),
|
||||||
userId = User.Identity.GetUserId(),
|
userId = User.Identity.GetUserId(),
|
||||||
roles = ((System.Security.Claims.ClaimsPrincipal)User).Claims
|
roles = ((ClaimsPrincipal)User).Claims
|
||||||
.Where(c => c.Type == System.Security.Claims.ClaimTypes.Role)
|
.Where(c => c.Type == ClaimTypes.Role)
|
||||||
.Select(role => role.Value)
|
.Select(role => role.Value),
|
||||||
|
claims = ((ClaimsPrincipal)User).Claims
|
||||||
|
.Where(c => c.Type.StartsWith("app-", StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Select(role => new { role.Type, role.Value })
|
||||||
},
|
},
|
||||||
new { id = "userDetails" })*@
|
new { id = "userDetails" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -36,11 +40,11 @@ else
|
||||||
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink", app_login_link = "" })</li>
|
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink", app_login_link = "" })</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@*@Html.Json(new {
|
@Html.Json(new {
|
||||||
isAuthenticated = false,
|
isAuthenticated = false,
|
||||||
userName = (string)null,
|
userName = (string)null,
|
||||||
userId = (string)null,
|
userId = (string)null,
|
||||||
roles = Enumerable.Empty<string>()
|
roles = Enumerable.Empty<string>()
|
||||||
},
|
},
|
||||||
new { id = "userDetails" })*@
|
new { id = "userDetails" })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<h2>Album <small>{{ viewModel.mode | titlecase }}</small></h2>
|
<h2>Album <small>{{ viewModel.mode | titlecase }}</small></h2>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<alert ng-show="viewModel.alert" type="{{ viewModel.alert.type.toString() }}" close="viewModel.clearAlert()">
|
<alert ng-show="viewModel.alert" type="{{ viewModel.alert.type.value }}" close="viewModel.clearAlert()">
|
||||||
{{ viewModel.alert.message }}
|
{{ viewModel.alert.message }}
|
||||||
<ul ng-show="viewModel.alert.modelErrors">
|
<ul ng-show="viewModel.alert.modelErrors">
|
||||||
<li ng-repeat="modelError in viewModel.alert.modelErrors">{{ modelError.ErrorMessage }}</li>
|
<li ng-repeat="modelError in viewModel.alert.modelErrors">{{ modelError.ErrorMessage }}</li>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<a class="btn btn-default" href="#/albums/new">Create new</a>
|
<a class="btn btn-default" href="#/albums/new">Create new</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<alert ng-show="viewModel.alert" type="{{ viewModel.alert.type.toString() }}" close="viewModel.clearAlert()">
|
<alert ng-show="viewModel.alert" type="{{ viewModel.alert.type.value }}" close="viewModel.clearAlert()">
|
||||||
{{ viewModel.alert.message }}
|
{{ viewModel.alert.message }}
|
||||||
<ul ng-show="viewModel.alert.modelErrors">
|
<ul ng-show="viewModel.alert.modelErrors">
|
||||||
<li ng-repeat="modelError in viewModel.alert.modelErrors">{{ modelError.ErrorMessage }}</li>
|
<li ng-repeat="modelError in viewModel.alert.modelErrors">{{ modelError.ErrorMessage }}</li>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ module MusicStore.Admin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this method to register work which should be performed when the injector is done loading all modules.
|
// Use this method to register work which should be performed when the injector is done loading all modules.
|
||||||
//function BUG:run() {
|
function run($log: ng.ILogService, userDetails: UserDetails.IUserDetailsService) {
|
||||||
|
$log.log(userDetails.getUserDetails());
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1028,6 +1028,10 @@ var MusicStore;
|
||||||
"$routeProvider",
|
"$routeProvider",
|
||||||
"$logProvider",
|
"$logProvider",
|
||||||
configuration
|
configuration
|
||||||
|
]).run([
|
||||||
|
"$log",
|
||||||
|
"MusicStore.UserDetails.IUserDetailsService",
|
||||||
|
run
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var dependencies = [
|
var dependencies = [
|
||||||
|
|
@ -1053,6 +1057,10 @@ var MusicStore;
|
||||||
|
|
||||||
$routeProvider.when("/albums/:albumId/details", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDetails.cshtml" }).when("/albums/:albumId/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" }).when("/albums/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" }).when("/albums", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumList.cshtml" }).otherwise({ redirectTo: "/albums" });
|
$routeProvider.when("/albums/:albumId/details", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDetails.cshtml" }).when("/albums/:albumId/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" }).when("/albums/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" }).when("/albums", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumList.cshtml" }).otherwise({ redirectTo: "/albums" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run($log, userDetails) {
|
||||||
|
$log.log(userDetails.getUserDetails());
|
||||||
|
}
|
||||||
})(MusicStore.Admin || (MusicStore.Admin = {}));
|
})(MusicStore.Admin || (MusicStore.Admin = {}));
|
||||||
var Admin = MusicStore.Admin;
|
var Admin = MusicStore.Admin;
|
||||||
})(MusicStore || (MusicStore = {}));
|
})(MusicStore || (MusicStore = {}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue