-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SG-58] Avatar color selector (#2330)
* chore: backend work * changed typing to match efc * Update User_Update.sql * fix: script cleanup * fix: adjust max length * fix: adjust max length * fix: added missing script changes * fix: use short form for creating objects * add: mysql migrations * chore: add mysql script * chore: posgres migrations * chore: postgres migrations * fix: lint * Update 20221115034053_AvatarColor.cs * fix: removed gravatar inline (#2447) Co-authored-by: Todd Martin <tmartin@bitwarden.com> Co-authored-by: Todd Martin <106564991+trmartin4@users.noreply.github.com>
- Loading branch information
Showing
17 changed files
with
3,709 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Api/Models/Request/Accounts/UpdateAvatarRequestModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Bit.Core.Entities; | ||
|
||
namespace Bit.Api.Models.Request.Accounts; | ||
|
||
public class UpdateAvatarRequestModel | ||
{ | ||
[StringLength(7)] | ||
public string AvatarColor { get; set; } | ||
|
||
public User ToUser(User existingUser) | ||
{ | ||
existingUser.AvatarColor = AvatarColor; | ||
return existingUser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
--Add column | ||
IF COL_LENGTH('[dbo].[User]', 'AvatarColor') IS NULL | ||
BEGIN | ||
ALTER TABLE [dbo].[User] ADD [AvatarColor] VARCHAR (7) NULL; | ||
END | ||
GO | ||
|
||
-- Recreate VIEW UserView | ||
CREATE OR ALTER VIEW [dbo].[UserView] | ||
AS | ||
SELECT | ||
* | ||
FROM | ||
[dbo].[User] | ||
GO | ||
|
||
-- Recreate procedure User_Update | ||
CREATE OR ALTER PROCEDURE [dbo].[User_Update] | ||
@Id UNIQUEIDENTIFIER, | ||
@Name NVARCHAR(50), | ||
@Email NVARCHAR(256), | ||
@EmailVerified BIT, | ||
@MasterPassword NVARCHAR(300), | ||
@MasterPasswordHint NVARCHAR(50), | ||
@Culture NVARCHAR(10), | ||
@SecurityStamp NVARCHAR(50), | ||
@TwoFactorProviders NVARCHAR(MAX), | ||
@TwoFactorRecoveryCode NVARCHAR(32), | ||
@EquivalentDomains NVARCHAR(MAX), | ||
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX), | ||
@AccountRevisionDate DATETIME2(7), | ||
@Key NVARCHAR(MAX), | ||
@PublicKey NVARCHAR(MAX), | ||
@PrivateKey NVARCHAR(MAX), | ||
@Premium BIT, | ||
@PremiumExpirationDate DATETIME2(7), | ||
@RenewalReminderDate DATETIME2(7), | ||
@Storage BIGINT, | ||
@MaxStorageGb SMALLINT, | ||
@Gateway TINYINT, | ||
@GatewayCustomerId VARCHAR(50), | ||
@GatewaySubscriptionId VARCHAR(50), | ||
@ReferenceData VARCHAR(MAX), | ||
@LicenseKey VARCHAR(100), | ||
@Kdf TINYINT, | ||
@KdfIterations INT, | ||
@CreationDate DATETIME2(7), | ||
@RevisionDate DATETIME2(7), | ||
@ApiKey VARCHAR(30), | ||
@ForcePasswordReset BIT = 0, | ||
@UsesKeyConnector BIT = 0, | ||
@FailedLoginCount INT, | ||
@LastFailedLoginDate DATETIME2(7), | ||
@UnknownDeviceVerificationEnabled BIT = 1, | ||
@AvatarColor VARCHAR(7) | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
UPDATE | ||
[dbo].[User] | ||
SET | ||
[Name] = @Name, | ||
[Email] = @Email, | ||
[EmailVerified] = @EmailVerified, | ||
[MasterPassword] = @MasterPassword, | ||
[MasterPasswordHint] = @MasterPasswordHint, | ||
[Culture] = @Culture, | ||
[SecurityStamp] = @SecurityStamp, | ||
[TwoFactorProviders] = @TwoFactorProviders, | ||
[TwoFactorRecoveryCode] = @TwoFactorRecoveryCode, | ||
[EquivalentDomains] = @EquivalentDomains, | ||
[ExcludedGlobalEquivalentDomains] = @ExcludedGlobalEquivalentDomains, | ||
[AccountRevisionDate] = @AccountRevisionDate, | ||
[Key] = @Key, | ||
[PublicKey] = @PublicKey, | ||
[PrivateKey] = @PrivateKey, | ||
[Premium] = @Premium, | ||
[PremiumExpirationDate] = @PremiumExpirationDate, | ||
[RenewalReminderDate] = @RenewalReminderDate, | ||
[Storage] = @Storage, | ||
[MaxStorageGb] = @MaxStorageGb, | ||
[Gateway] = @Gateway, | ||
[GatewayCustomerId] = @GatewayCustomerId, | ||
[GatewaySubscriptionId] = @GatewaySubscriptionId, | ||
[ReferenceData] = @ReferenceData, | ||
[LicenseKey] = @LicenseKey, | ||
[Kdf] = @Kdf, | ||
[KdfIterations] = @KdfIterations, | ||
[CreationDate] = @CreationDate, | ||
[RevisionDate] = @RevisionDate, | ||
[ApiKey] = @ApiKey, | ||
[ForcePasswordReset] = @ForcePasswordReset, | ||
[UsesKeyConnector] = @UsesKeyConnector, | ||
[FailedLoginCount] = @FailedLoginCount, | ||
[LastFailedLoginDate] = @LastFailedLoginDate, | ||
[UnknownDeviceVerificationEnabled] = @UnknownDeviceVerificationEnabled, | ||
[AvatarColor] = @AvatarColor | ||
WHERE | ||
[Id] = @Id | ||
END | ||
GO | ||
|
||
CREATE OR ALTER PROCEDURE [dbo].[User_Create] | ||
@Id UNIQUEIDENTIFIER OUTPUT, | ||
@Name NVARCHAR(50), | ||
@Email NVARCHAR(256), | ||
@EmailVerified BIT, | ||
@MasterPassword NVARCHAR(300), | ||
@MasterPasswordHint NVARCHAR(50), | ||
@Culture NVARCHAR(10), | ||
@SecurityStamp NVARCHAR(50), | ||
@TwoFactorProviders NVARCHAR(MAX), | ||
@TwoFactorRecoveryCode NVARCHAR(32), | ||
@EquivalentDomains NVARCHAR(MAX), | ||
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX), | ||
@AccountRevisionDate DATETIME2(7), | ||
@Key NVARCHAR(MAX), | ||
@PublicKey NVARCHAR(MAX), | ||
@PrivateKey NVARCHAR(MAX), | ||
@Premium BIT, | ||
@PremiumExpirationDate DATETIME2(7), | ||
@RenewalReminderDate DATETIME2(7), | ||
@Storage BIGINT, | ||
@MaxStorageGb SMALLINT, | ||
@Gateway TINYINT, | ||
@GatewayCustomerId VARCHAR(50), | ||
@GatewaySubscriptionId VARCHAR(50), | ||
@ReferenceData VARCHAR(MAX), | ||
@LicenseKey VARCHAR(100), | ||
@Kdf TINYINT, | ||
@KdfIterations INT, | ||
@CreationDate DATETIME2(7), | ||
@RevisionDate DATETIME2(7), | ||
@ApiKey VARCHAR(30), | ||
@ForcePasswordReset BIT = 0, | ||
@UsesKeyConnector BIT = 0, | ||
@FailedLoginCount INT = 0, | ||
@LastFailedLoginDate DATETIME2(7), | ||
@UnknownDeviceVerificationEnabled BIT = 1, | ||
@AvatarColor VARCHAR(7) = NULL | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
INSERT INTO [dbo].[User] | ||
( | ||
[Id], | ||
[Name], | ||
[Email], | ||
[EmailVerified], | ||
[MasterPassword], | ||
[MasterPasswordHint], | ||
[Culture], | ||
[SecurityStamp], | ||
[TwoFactorProviders], | ||
[TwoFactorRecoveryCode], | ||
[EquivalentDomains], | ||
[ExcludedGlobalEquivalentDomains], | ||
[AccountRevisionDate], | ||
[Key], | ||
[PublicKey], | ||
[PrivateKey], | ||
[Premium], | ||
[PremiumExpirationDate], | ||
[RenewalReminderDate], | ||
[Storage], | ||
[MaxStorageGb], | ||
[Gateway], | ||
[GatewayCustomerId], | ||
[GatewaySubscriptionId], | ||
[ReferenceData], | ||
[LicenseKey], | ||
[Kdf], | ||
[KdfIterations], | ||
[CreationDate], | ||
[RevisionDate], | ||
[ApiKey], | ||
[ForcePasswordReset], | ||
[UsesKeyConnector], | ||
[FailedLoginCount], | ||
[LastFailedLoginDate], | ||
[UnknownDeviceVerificationEnabled], | ||
[AvatarColor] | ||
) | ||
VALUES | ||
( | ||
@Id, | ||
@Name, | ||
@Email, | ||
@EmailVerified, | ||
@MasterPassword, | ||
@MasterPasswordHint, | ||
@Culture, | ||
@SecurityStamp, | ||
@TwoFactorProviders, | ||
@TwoFactorRecoveryCode, | ||
@EquivalentDomains, | ||
@ExcludedGlobalEquivalentDomains, | ||
@AccountRevisionDate, | ||
@Key, | ||
@PublicKey, | ||
@PrivateKey, | ||
@Premium, | ||
@PremiumExpirationDate, | ||
@RenewalReminderDate, | ||
@Storage, | ||
@MaxStorageGb, | ||
@Gateway, | ||
@GatewayCustomerId, | ||
@GatewaySubscriptionId, | ||
@ReferenceData, | ||
@LicenseKey, | ||
@Kdf, | ||
@KdfIterations, | ||
@CreationDate, | ||
@RevisionDate, | ||
@ApiKey, | ||
@ForcePasswordReset, | ||
@UsesKeyConnector, | ||
@FailedLoginCount, | ||
@LastFailedLoginDate, | ||
@UnknownDeviceVerificationEnabled, | ||
@AvatarColor | ||
) | ||
END |
Oops, something went wrong.