diff --git a/SystemKonkursow/4.2.1/angular/src/account/register/register.component.html b/SystemKonkursow/4.2.1/angular/src/account/register/register.component.html
index 4a3b89c..7663dd1 100644
--- a/SystemKonkursow/4.2.1/angular/src/account/register/register.component.html
+++ b/SystemKonkursow/4.2.1/angular/src/account/register/register.component.html
@@ -38,6 +38,32 @@
+
+
+
+
diff --git a/SystemKonkursow/4.2.1/angular/src/account/register/register.component.ts b/SystemKonkursow/4.2.1/angular/src/account/register/register.component.ts
index 673b009..7ca57b7 100644
--- a/SystemKonkursow/4.2.1/angular/src/account/register/register.component.ts
+++ b/SystemKonkursow/4.2.1/angular/src/account/register/register.component.ts
@@ -1,4 +1,4 @@
-import { Component, Injector, ElementRef, AfterViewInit, ViewChild } from '@angular/core';
+import { Component, Injector, ElementRef, OnInit, AfterViewInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { AccountServiceProxy, RegisterInput, RegisterOutput } from '@shared/service-proxies/service-proxies'
import { AppComponentBase } from '@shared/app-component-base';
@@ -10,7 +10,7 @@ import { finalize } from 'rxjs/operators';
templateUrl: './register.component.html',
animations: [accountModuleAnimation()]
})
-export class RegisterComponent extends AppComponentBase implements AfterViewInit {
+export class RegisterComponent extends AppComponentBase implements OnInit, AfterViewInit {
@ViewChild('cardBody') cardBody: ElementRef;
@@ -18,6 +18,22 @@ export class RegisterComponent extends AppComponentBase implements AfterViewInit
saving: boolean = false;
+ public possibleClasses = [
+ {value: 1, viewValue: 'Klasa 1'},
+ {value: 2, viewValue: 'Klasa 2'},
+ {value: 3, viewValue: 'Klasa 3'},
+ {value: 4, viewValue: 'Klasa 4'},
+ {value: 5, viewValue: 'Klasa 5'},
+ {value: 6, viewValue: 'Klasa 6'},
+ {value: 7, viewValue: 'Klasa 7'},
+ {value: 8, viewValue: 'Klasa 8'}
+ ];
+
+ public possibleRoles = [
+ {value: 'Participant', viewValue: 'Uczestnik'},
+ {value: 'Organizer', viewValue: 'Organizator'}
+ ];
+
constructor(
injector: Injector,
private _accountService: AccountServiceProxy,
@@ -30,12 +46,22 @@ export class RegisterComponent extends AppComponentBase implements AfterViewInit
ngAfterViewInit(): void {
$(this.cardBody.nativeElement).find('input:first').focus();
}
+
+ ngOnInit(): void {
+ this.model.role = 'Participant';
+ this.model.participantClass = 1;
+ }
back(): void {
this._router.navigate(['/login']);
}
save(): void {
+ if (this.model.role === 'Organizer') {
+ this.model.participantClass = 0;
+ }
+
+ this.model.participantClass = +this.model.participantClass;
this.saving = true;
this._accountService.register(this.model)
.pipe(finalize(() => { this.saving = false; }))
diff --git a/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts b/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
index b0d7c2e..0372399 100644
--- a/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
+++ b/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
@@ -1880,6 +1880,8 @@ export class RegisterInput implements IRegisterInput {
userName: string;
emailAddress: string;
password: string;
+ role: string;
+ participantClass: number;
captchaResponse: string | undefined;
constructor(data?: IRegisterInput) {
@@ -1898,6 +1900,8 @@ export class RegisterInput implements IRegisterInput {
this.userName = data["userName"];
this.emailAddress = data["emailAddress"];
this.password = data["password"];
+ this.role = data["role"];
+ this.participantClass = data["participantClass"];
this.captchaResponse = data["captchaResponse"];
}
}
@@ -1916,6 +1920,8 @@ export class RegisterInput implements IRegisterInput {
data["userName"] = this.userName;
data["emailAddress"] = this.emailAddress;
data["password"] = this.password;
+ data["role"] = this.role;
+ data["participantClass"] = this.participantClass;
data["captchaResponse"] = this.captchaResponse;
return data;
}
@@ -1934,6 +1940,8 @@ export interface IRegisterInput {
userName: string;
emailAddress: string;
password: string;
+ role: string;
+ participantClass: number;
captchaResponse: string | undefined;
}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/AccountAppService.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/AccountAppService.cs
index 50ff768..c9d2d92 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/AccountAppService.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/AccountAppService.cs
@@ -66,6 +66,8 @@ namespace SystemKonkursow.Authorization.Accounts
input.EmailAddress,
input.UserName,
input.Password,
+ input.Role,
+ input.ParticipantClass,
true // Assumed email address is always confirmed. Change this if you want to implement email confirmation.
);
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/Dto/RegisterInput.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/Dto/RegisterInput.cs
index 49954fc..4c26dd4 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/Dto/RegisterInput.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Authorization/Accounts/Dto/RegisterInput.cs
@@ -31,6 +31,12 @@ namespace SystemKonkursow.Authorization.Accounts.Dto
[DisableAuditing]
public string Password { get; set; }
+ [Required]
+ public string Role { get; set; }
+
+ [Required]
+ public int ParticipantClass { get; set; }
+
[DisableAuditing]
public string CaptchaResponse { get; set; }
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Authorization/Users/UserRegistrationManager.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Authorization/Users/UserRegistrationManager.cs
index 252c6ab..00e6edf 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Authorization/Users/UserRegistrationManager.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Authorization/Users/UserRegistrationManager.cs
@@ -11,6 +11,8 @@ using Abp.Runtime.Session;
using Abp.UI;
using SystemKonkursow.Authorization.Roles;
using SystemKonkursow.MultiTenancy;
+using SystemKonkursow.Domain;
+using Abp.Domain.Repositories;
namespace SystemKonkursow.Authorization.Users
{
@@ -22,22 +24,25 @@ namespace SystemKonkursow.Authorization.Users
private readonly UserManager _userManager;
private readonly RoleManager _roleManager;
private readonly IPasswordHasher _passwordHasher;
+ private readonly IRepository _participantRepository;
public UserRegistrationManager(
TenantManager tenantManager,
UserManager userManager,
RoleManager roleManager,
- IPasswordHasher passwordHasher)
+ IPasswordHasher passwordHasher,
+ IRepository participantRepository)
{
_tenantManager = tenantManager;
_userManager = userManager;
_roleManager = roleManager;
_passwordHasher = passwordHasher;
+ _participantRepository = participantRepository;
AbpSession = NullAbpSession.Instance;
}
- public async Task RegisterAsync(string name, string surname, string emailAddress, string userName, string plainPassword, bool isEmailConfirmed)
+ public async Task RegisterAsync(string name, string surname, string emailAddress, string userName, string plainPassword, string role, int participantClass, bool isEmailConfirmed)
{
CheckForTenant();
@@ -56,7 +61,19 @@ namespace SystemKonkursow.Authorization.Users
};
user.SetNormalizedNames();
-
+
+ if (role == "Participant")
+ {
+ var participantRole = _roleManager.Roles.IgnoreQueryFilters().FirstOrDefault(r => r.TenantId == tenant.Id && r.Name == StaticRoleNames.Host.Participant);
+ user.Roles.Add(new UserRole(tenant.Id, user.Id, participantRole.Id));
+ }
+
+ if (role == "Organizer")
+ {
+ var organizerRole = _roleManager.Roles.IgnoreQueryFilters().FirstOrDefault(r => r.TenantId == tenant.Id && r.Name == StaticRoleNames.Host.Organizer);
+ user.Roles.Add(new UserRole(tenant.Id, user.Id, organizerRole.Id));
+ }
+
foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
{
user.Roles.Add(new UserRole(tenant.Id, user.Id, defaultRole.Id));
@@ -65,6 +82,18 @@ namespace SystemKonkursow.Authorization.Users
await _userManager.InitializeOptionsAsync(tenant.Id);
CheckErrors(await _userManager.CreateAsync(user, plainPassword));
+
+ if (participantClass != 0)
+ {
+ var participant = new Participant
+ {
+ UserId = user.Id,
+ ParticipantClass = participantClass
+ };
+
+ _participantRepository.Insert(participant);
+ }
+
await CurrentUnitOfWork.SaveChangesAsync();
return user;
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Domain/Participant.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Domain/Participant.cs
new file mode 100644
index 0000000..e4186d6
--- /dev/null
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Core/Domain/Participant.cs
@@ -0,0 +1,17 @@
+using Abp.Domain.Entities;
+using System.ComponentModel.DataAnnotations.Schema;
+using SystemKonkursow.Authorization.Users;
+
+namespace SystemKonkursow.Domain
+{
+ [Table("Participants")]
+ public class Participant : Entity
+ {
+ public long UserId { get; set; }
+
+ public int ParticipantClass { get; set; }
+
+ [ForeignKey(nameof(UserId))]
+ public virtual User User { get; set; }
+ }
+}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/Seed/UserBuilder.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/Seed/UserBuilder.cs
index 7a97c47..37cc801 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/Seed/UserBuilder.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/Seed/UserBuilder.cs
@@ -3,11 +3,13 @@ using Abp.Authorization.Users;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using SystemKonkursow.Authorization;
using SystemKonkursow.Authorization.Roles;
using SystemKonkursow.Authorization.Users;
+using SystemKonkursow.Domain;
namespace SystemKonkursow.EntityFrameworkCore.Seed
{
@@ -30,14 +32,14 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
//list permissions
});
- CreateUser(new List { organizerRole }, "Jan", "Kowalski", "organizator", "organizator@example.com");
+ CreateUser(new List { organizerRole }, "Jan", "Kowalski", "organizator", "organizator@example.com", false);
Role participantRole = CreateRole(StaticRoleNames.Host.Participant, new List {
PermissionNames.Pages_Solve_Competition
//list permissions
});
- CreateUser(new List { participantRole }, "Jerzy", "Nowak", "uczestnik", "uczestnik@example.com");
+ CreateUser(new List { participantRole }, "Jerzy", "Nowak", "uczestnik", "uczestnik@example.com", true);
}
private Role CreateRole(string roleName, IList permissionList)
@@ -63,8 +65,10 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
return role;
}
- private void CreateUser(IEnumerable roles, string name, string surname, string userName, string emailAddress)
+ private void CreateUser(IEnumerable roles, string name, string surname, string userName, string emailAddress, bool isParticipant)
{
+ Random rnd = new Random();
+
var user = _context.Users.IgnoreQueryFilters()
.FirstOrDefault(u => u.TenantId == 1 && u.UserName == userName);
if (null == user)
@@ -86,6 +90,18 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
_context.Users.Add(user);
_context.SaveChanges();
+ if (isParticipant)
+ {
+ var participant = new Participant()
+ {
+ UserId = user.Id,
+ ParticipantClass = rnd.Next(1, 9)
+ };
+
+ _context.Participants.Add(participant);
+ _context.SaveChanges();
+ }
+
// Assign role to user
foreach (var role in roles)
{
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/SystemKonkursowDbContext.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/SystemKonkursowDbContext.cs
index 5de643e..7a9d93e 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/SystemKonkursowDbContext.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/EntityFrameworkCore/SystemKonkursowDbContext.cs
@@ -16,6 +16,8 @@ namespace SystemKonkursow.EntityFrameworkCore
}
+ public DbSet Participants { get; set; }
+
public DbSet CompetitionCategories { get; set; }
public DbSet Categories { get; set; }
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/Migrations/SystemKonkursowDbContextModelSnapshot.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/Migrations/SystemKonkursowDbContextModelSnapshot.cs
index 20accc7..75d1d37 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/Migrations/SystemKonkursowDbContextModelSnapshot.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/Migrations/SystemKonkursowDbContextModelSnapshot.cs
@@ -1081,6 +1081,23 @@ namespace SystemKonkursow.Migrations
b.ToTable("CompetitionCategories");
});
+ modelBuilder.Entity("SystemKonkursow.Domain.Participant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ParticipantClass");
+
+ b.Property("UserId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Participants");
+ });
+
modelBuilder.Entity("SystemKonkursow.MultiTenancy.Tenant", b =>
{
b.Property("Id")
@@ -1302,6 +1319,14 @@ namespace SystemKonkursow.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
+ modelBuilder.Entity("SystemKonkursow.Domain.Participant", b =>
+ {
+ b.HasOne("SystemKonkursow.Authorization.Users.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
modelBuilder.Entity("SystemKonkursow.MultiTenancy.Tenant", b =>
{
b.HasOne("SystemKonkursow.Authorization.Users.User", "CreatorUser")
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/SystemKonkursow.EntityFrameworkCore.csproj b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/SystemKonkursow.EntityFrameworkCore.csproj
index dcbd57e..68c6fa9 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/SystemKonkursow.EntityFrameworkCore.csproj
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.EntityFrameworkCore/SystemKonkursow.EntityFrameworkCore.csproj
@@ -25,4 +25,7 @@
+
+
+
\ No newline at end of file
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Web.Core/Controllers/TokenAuthController.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Web.Core/Controllers/TokenAuthController.cs
index 1700a17..c8ae909 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Web.Core/Controllers/TokenAuthController.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Web.Core/Controllers/TokenAuthController.cs
@@ -141,6 +141,8 @@ namespace SystemKonkursow.Controllers
externalUser.EmailAddress,
externalUser.EmailAddress,
Authorization.Users.User.CreateRandomPassword(),
+ "Organizer",
+ 0,
true
);