mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Fixed the user management #865
This commit is contained in:
parent
3879fc04de
commit
5ac0e4c68a
6 changed files with 35 additions and 13 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Claims;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
@ -71,6 +72,7 @@ namespace Ombi.Core.IdentityResolver
|
||||||
public async Task<UserDto> CreateUser(UserDto userDto)
|
public async Task<UserDto> CreateUser(UserDto userDto)
|
||||||
{
|
{
|
||||||
var user = Mapper.Map<User>(userDto);
|
var user = Mapper.Map<User>(userDto);
|
||||||
|
user.Claims.RemoveAll(x => x.Type == ClaimTypes.Country); // This is a hack around the Mapping Profile
|
||||||
var result = HashPassword(user.Password);
|
var result = HashPassword(user.Password);
|
||||||
user.Password = result.HashedPass;
|
user.Password = result.HashedPass;
|
||||||
user.Salt = result.Salt;
|
user.Salt = result.Salt;
|
||||||
|
|
|
@ -9,25 +9,38 @@ namespace Ombi.Helpers
|
||||||
{
|
{
|
||||||
public override bool CanConvert(Type objectType)
|
public override bool CanConvert(Type objectType)
|
||||||
{
|
{
|
||||||
return (objectType == typeof(Claim));
|
return (objectType == typeof(System.Security.Claims.Claim));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var claim = (System.Security.Claims.Claim)value;
|
||||||
|
JObject jo = new JObject();
|
||||||
|
jo.Add("Type", claim.Type);
|
||||||
|
jo.Add("Value", IsJson(claim.Value) ? new JRaw(claim.Value) : new JValue(claim.Value));
|
||||||
|
jo.Add("ValueType", claim.ValueType);
|
||||||
|
jo.Add("Issuer", claim.Issuer);
|
||||||
|
jo.Add("OriginalIssuer", claim.OriginalIssuer);
|
||||||
|
jo.WriteTo(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
JObject jo = JObject.Load(reader);
|
JObject jo = JObject.Load(reader);
|
||||||
string type = (string)jo["Type"];
|
string type = (string)jo["Type"];
|
||||||
string value = (string)jo["Value"];
|
JToken token = jo["Value"];
|
||||||
|
string value = token.Type == JTokenType.String ? (string)token : token.ToString(Formatting.None);
|
||||||
string valueType = (string)jo["ValueType"];
|
string valueType = (string)jo["ValueType"];
|
||||||
string issuer = (string)jo["Issuer"];
|
string issuer = (string)jo["Issuer"];
|
||||||
string originalIssuer = (string)jo["OriginalIssuer"];
|
string originalIssuer = (string)jo["OriginalIssuer"];
|
||||||
return new Claim(type, value, valueType, issuer, originalIssuer);
|
return new Claim(type, value, valueType, issuer, originalIssuer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanWrite => false;
|
private bool IsJson(string val)
|
||||||
|
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return (val != null &&
|
||||||
|
(val.StartsWith("[") && val.EndsWith("]")) ||
|
||||||
|
(val.StartsWith("{") && val.EndsWith("}")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ namespace Ombi.Mapping.Profiles
|
||||||
CreateMap<UserDto, UserViewModel>().ForMember(x => x.Password, opt => opt.Ignore());
|
CreateMap<UserDto, UserViewModel>().ForMember(x => x.Password, opt => opt.Ignore());
|
||||||
|
|
||||||
CreateMap<ClaimCheckboxes, Claim>()
|
CreateMap<ClaimCheckboxes, Claim>()
|
||||||
.ConstructUsing(checkbox => checkbox.Enabled ? new Claim(ClaimTypes.Role, checkbox.Value) : null);
|
.ConstructUsing(checkbox => checkbox.Enabled ? new Claim(ClaimTypes.Role, checkbox.Value) : new Claim(ClaimTypes.Country, ""));
|
||||||
// This is used for the UserViewModel List<string> claims => UserDto List<claim>
|
// This is used for the UserViewModel List<string> claims => UserDto List<claim>
|
||||||
CreateMap<UserViewModel, UserDto>();
|
CreateMap<UserViewModel, UserDto>();
|
||||||
|
|
||||||
|
|
|
@ -108,4 +108,8 @@
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="wwwroot\app\settings\NewFolder\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { LoginComponent } from './login/login.component';
|
||||||
import { LandingPageComponent } from './landingpage/landingpage.component';
|
import { LandingPageComponent } from './landingpage/landingpage.component';
|
||||||
import { UserManagementComponent } from './usermanagement/usermanagement.component';
|
import { UserManagementComponent } from './usermanagement/usermanagement.component';
|
||||||
import { PageNotFoundComponent } from './errors/not-found.component';
|
import { PageNotFoundComponent } from './errors/not-found.component';
|
||||||
|
import { UserModalComponent } from './usermanagement/usermodal.component';
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { SearchService } from './services/search.service';
|
import { SearchService } from './services/search.service';
|
||||||
|
@ -91,7 +92,8 @@ const routes: Routes = [
|
||||||
UserManagementComponent,
|
UserManagementComponent,
|
||||||
MovieRequestsComponent,
|
MovieRequestsComponent,
|
||||||
TvRequestsComponent,
|
TvRequestsComponent,
|
||||||
SeriesInformationComponent
|
SeriesInformationComponent,
|
||||||
|
UserModalComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
SearchService,
|
SearchService,
|
||||||
|
|
|
@ -109,8 +109,8 @@
|
||||||
<div *ngFor="let c of selectedUser.claims">
|
<div *ngFor="let c of selectedUser.claims">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label for="claim{{c.value}}">{{c.value}}</label>
|
<input type="checkbox" [(ngModel)]="c.enabled" [value]="c.value" id="create{{c.value}}" [attr.name]="'create' + c.value" ng-checked="c.enabled">
|
||||||
<input type="checkbox" [(ngModel)]="c.enabled" [value]="c.value" [checked]="c.value" id="claim{{c.value}}" name="claim{{c.value}}" ng-checked="c.enabled">
|
<label for="create{{c.value}}">{{c.value}}</label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -127,6 +127,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="modal fade in " *ngIf="showCreateDialogue" style="display: block;">
|
<div class="modal fade in " *ngIf="showCreateDialogue" style="display: block;">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
@ -167,9 +169,8 @@
|
||||||
<div *ngFor="let c of availableClaims">
|
<div *ngFor="let c of availableClaims">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
<input type="checkbox" [(ngModel)]="c.enabled" [value]="c.value" id="create{{c.value}}" [attr.name]="'create' + c.value" ng-checked="c.enabled">
|
||||||
<label for="create{{c.value}}">{{c.value}}</label>
|
<label for="create{{c.value}}">{{c.value}}</label>
|
||||||
<input type="checkbox" [(ngModel)]="c.enabled" [value]="c.value" [checked]="c.value" id="create{{c.value}}" name="create{{c.value}}" ng-checked="c.enabled">
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue