mirror of https://github.com/Squidex/squidex.git
committed by
GitHub
266 changed files with 13162 additions and 8511 deletions
@ -0,0 +1,96 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.IO; |
|||
using System.Security.Cryptography; |
|||
|
|||
namespace Squidex.Infrastructure.Assets |
|||
{ |
|||
public sealed class HasherStream : Stream |
|||
{ |
|||
private readonly Stream inner; |
|||
private readonly IncrementalHash hasher; |
|||
|
|||
public override bool CanRead |
|||
{ |
|||
get { return inner.CanRead; } |
|||
} |
|||
|
|||
public override bool CanSeek |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
public override bool CanWrite |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
public override long Length |
|||
{ |
|||
get { return inner.Length; } |
|||
} |
|||
|
|||
public override long Position |
|||
{ |
|||
get { return inner.Position; } |
|||
set { throw new NotSupportedException(); } |
|||
} |
|||
|
|||
public HasherStream(Stream inner, HashAlgorithmName hashAlgorithmName) |
|||
{ |
|||
Guard.NotNull(inner, nameof(inner)); |
|||
|
|||
this.inner = inner; |
|||
|
|||
hasher = IncrementalHash.CreateHash(hashAlgorithmName); |
|||
} |
|||
|
|||
public override int Read(byte[] buffer, int offset, int count) |
|||
{ |
|||
var read = inner.Read(buffer, offset, count); |
|||
|
|||
if (read > 0) |
|||
{ |
|||
hasher.AppendData(buffer, offset, read); |
|||
} |
|||
|
|||
return read; |
|||
} |
|||
|
|||
public byte[] GetHashAndReset() |
|||
{ |
|||
return hasher.GetHashAndReset(); |
|||
} |
|||
|
|||
public string GetHashStringAndReset() |
|||
{ |
|||
return Convert.ToBase64String(GetHashAndReset()); |
|||
} |
|||
|
|||
public override void Flush() |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
|
|||
public override long Seek(long offset, SeekOrigin origin) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
|
|||
public override void SetLength(long value) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
|
|||
public override void Write(byte[] buffer, int offset, int count) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
export * from './services/event-consumers.service'; |
|||
export * from './services/users.service'; |
|||
|
|||
export * from './state/event-consumers.state'; |
|||
export * from './state/users.forms'; |
|||
export * from './state/users.state'; |
|||
@ -0,0 +1,46 @@ |
|||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|||
|
|||
import { Form, ValidatorsEx } from '@app/shared'; |
|||
|
|||
import { UpdateUserDto } from './../services/users.service'; |
|||
|
|||
export class UserForm extends Form<FormGroup, UpdateUserDto> { |
|||
constructor( |
|||
formBuilder: FormBuilder |
|||
) { |
|||
super(formBuilder.group({ |
|||
email: ['', |
|||
[ |
|||
Validators.email, |
|||
Validators.required, |
|||
Validators.maxLength(100) |
|||
] |
|||
], |
|||
displayName: ['', |
|||
[ |
|||
Validators.required, |
|||
Validators.maxLength(100) |
|||
] |
|||
], |
|||
password: ['', |
|||
[ |
|||
Validators.nullValidator |
|||
] |
|||
], |
|||
passwordConfirm: ['', |
|||
[ |
|||
ValidatorsEx.match('password', 'Passwords must be the same.') |
|||
] |
|||
], |
|||
permissions: [''] |
|||
})); |
|||
} |
|||
|
|||
protected transformLoad(user: UpdateUserDto) { |
|||
return { ...user, permissions: user.permissions.join('\n') }; |
|||
} |
|||
|
|||
protected transformSubmit(value: any): UpdateUserDto { |
|||
return { ...value, permissions: value['permissions'].split('\n').filter((x: any) => !!x) }; |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue