Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lesson49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Пасько Виталий
Lesson49
Commits
64522670
Commit
64522670
authored
Jul 21, 2022
by
Пасько Виталий
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: пофиксил ошибку из-за того, что не изменил наследование пользователя на IdentityUser.
parent
20fd6d08
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
284 additions
and
11 deletions
+284
-11
AccountController.cs
PhoneStore/Controllers/AccountController.cs
+8
-0
MobileContextModelSnapshot.cs
PhoneStore/Migrations/MobileContextModelSnapshot.cs
+252
-0
MobileContext.cs
PhoneStore/Models/MobileContext.cs
+2
-1
Program.cs
PhoneStore/Program.cs
+1
-1
IAccountService.cs
PhoneStore/Services/Abstractions/IAccountService.cs
+1
-1
AccountService.cs
PhoneStore/Services/AccountService.cs
+2
-5
AdminInitializerService.cs
PhoneStore/Services/AdminInitializerService.cs
+1
-1
Startup.cs
PhoneStore/Startup.cs
+1
-1
_Layout.cshtml
PhoneStore/Views/Shared/_Layout.cshtml
+15
-0
appsettings.json
PhoneStore/appsettings.json
+1
-1
No files found.
PhoneStore/Controllers/AccountController.cs
View file @
64522670
...
...
@@ -66,5 +66,13 @@ namespace PhoneStore.Controllers
return
View
(
model
);
}
[
HttpPost
]
[
ValidateAntiForgeryToken
]
public
async
Task
<
IActionResult
>
LogOff
()
{
await
_accountService
.
LogOf
();
return
RedirectToAction
(
"Index"
,
"Phones"
);
}
}
}
\ No newline at end of file
PhoneStore/Migrations/MobileContextModelSnapshot.cs
View file @
64522670
This diff is collapsed.
Click to expand it.
PhoneStore/Models/MobileContext.cs
View file @
64522670
using
Microsoft.AspNetCore.Identity.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
namespace
PhoneStore.Models
{
public
class
MobileContext
:
DbContext
public
class
MobileContext
:
IdentityDbContext
<
User
,
Role
,
int
>
{
public
DbSet
<
Phone
>
Phones
{
get
;
set
;
}
public
DbSet
<
Order
>
Orders
{
get
;
set
;
}
...
...
PhoneStore/Program.cs
View file @
64522670
...
...
@@ -24,7 +24,7 @@ namespace PhoneStore
{
var
userManager
=
services
.
GetRequiredService
<
UserManager
<
User
>>();
RoleManager
<
Role
>
rolesManager
=
services
.
GetRequiredService
<
RoleManager
<
Role
>>();
await
AdminInitializer
.
SeedAdminUser
(
rolesManager
,
userManager
);
await
AdminInitializer
Service
.
SeedAdminUser
(
rolesManager
,
userManager
);
}
catch
(
Exception
ex
)
{
...
...
PhoneStore/Services/Abstractions/IAccountService.cs
View file @
64522670
...
...
@@ -8,6 +8,6 @@ namespace PhoneStore.Services.Abstractions
{
Task
<
IdentityResult
>
Register
(
RegisterViewModel
model
);
Task
<
IdentityResult
>
LogIn
(
LoginViewModel
model
);
Task
<
IdentityResult
>
LogOf
();
Task
LogOf
();
}
}
\ No newline at end of file
PhoneStore/Services/AccountService.cs
View file @
64522670
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security.Policy
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Identity
;
using
PhoneStore.Enums
;
...
...
@@ -73,9 +72,7 @@ namespace PhoneStore.Services
};
}
public
Task
<
IdentityResult
>
LogOf
()
{
throw
new
System
.
NotImplementedException
();
}
public
async
Task
LogOf
()
=>
await
_signInManager
.
SignOutAsync
();
}
}
\ No newline at end of file
PhoneStore/Services/AdminInitializer.cs
→
PhoneStore/Services/AdminInitializer
Service
.cs
View file @
64522670
...
...
@@ -4,7 +4,7 @@ using PhoneStore.Models;
namespace
PhoneStore.Services
{
public
class
AdminInitializer
public
class
AdminInitializer
Service
{
public
static
async
Task
SeedAdminUser
(
RoleManager
<
Role
>
roleManager
,
...
...
PhoneStore/Startup.cs
View file @
64522670
...
...
@@ -50,7 +50,7 @@ namespace PhoneStore
app
.
UseStaticFiles
();
app
.
UseRouting
();
app
.
UseAuthorization
().
UseAuthentication
();
app
.
UseEndpoints
(
endpoints
=>
{
endpoints
.
MapControllerRoute
(
...
...
PhoneStore/Views/Shared/_Layout.cshtml
View file @
64522670
...
...
@@ -29,6 +29,21 @@
</li>
</ul>
</div>
<div
class=
"login_group"
>
@if(User.Identity.IsAuthenticated)
{
<p>
@User.Identity.Name
</p>
<form
method=
"post"
asp-controller=
"Account"
asp-action=
"LogOff"
>
<input
type=
"submit"
value=
"Выход"
/>
</form>
}
else
{
<a
asp-controller=
"Account"
asp-action=
"Login"
>
Вход
</a>
<a
asp-controller=
"Account"
asp-action=
"Register"
>
Регистрация
</a>
}
</div>
</div>
</nav>
</header>
...
...
PhoneStore/appsettings.json
View file @
64522670
{
"ConnectionStrings"
:
{
"DefaultConnection"
:
"Server=localhost;Port=54320;database=lesson5
5
;Username=postgres;Password=postgres;"
"DefaultConnection"
:
"Server=localhost;Port=54320;database=lesson5
8
;Username=postgres;Password=postgres;"
},
"Logging"
:
{
"LogLevel"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment