mirror of
https://github.com/bitwarden/server.git
synced 2025-04-11 08:08:14 -05:00
restore new change pass and email apis
This commit is contained in:
parent
c1123b1959
commit
848e94ad56
@ -10,7 +10,6 @@ using Bit.Core.Models.Table;
|
|||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Bit.Api.Controllers
|
namespace Bit.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -76,32 +75,16 @@ namespace Bit.Api.Controllers
|
|||||||
|
|
||||||
[HttpPut("email")]
|
[HttpPut("email")]
|
||||||
[HttpPost("email")]
|
[HttpPost("email")]
|
||||||
public async Task PutEmail([FromBody]EmailRequestModel_Old model)
|
public async Task PutEmail([FromBody]EmailRequestModel model)
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByPrincipalAsync(User);
|
var user = await _userService.GetUserByPrincipalAsync(User);
|
||||||
|
|
||||||
// NOTE: It is assumed that the eventual repository call will make sure the updated
|
// NOTE: It is assumed that the eventual repository call will make sure the updated
|
||||||
// ciphers belong to user making this call. Therefore, no check is done here.
|
// ciphers belong to user making this call. Therefore, no check is done here.
|
||||||
|
|
||||||
//var ciphers = model.Data.Ciphers.Select(c => c.ToCipher(user.Id));
|
var ciphers = model.Data.Ciphers.Select(c => c.ToCipher(user.Id));
|
||||||
//var folders = model.Data.Folders.Select(c => c.ToFolder(user.Id));
|
var folders = model.Data.Folders.Select(c => c.ToFolder(user.Id));
|
||||||
|
|
||||||
//var result = await _userService.ChangeEmailAsync(
|
|
||||||
// user,
|
|
||||||
// model.MasterPasswordHash,
|
|
||||||
// model.NewEmail,
|
|
||||||
// model.NewMasterPasswordHash,
|
|
||||||
// model.Token,
|
|
||||||
// ciphers,
|
|
||||||
// folders,
|
|
||||||
// model.Data.PrivateKey);
|
|
||||||
|
|
||||||
//
|
|
||||||
// NOTE: Temporary backwards compat. Remove the below and uncomment the above whenever web vault v1.10.0 is released
|
|
||||||
//
|
|
||||||
|
|
||||||
var ciphers = model.Ciphers.Where(c => c.Type == CipherType.Login).Select(c => c.ToCipher(user.Id));
|
|
||||||
var folders = model.Ciphers.Where(c => c.Type == CipherType.Folder).Select(c => c.ToFolder(user.Id));
|
|
||||||
var result = await _userService.ChangeEmailAsync(
|
var result = await _userService.ChangeEmailAsync(
|
||||||
user,
|
user,
|
||||||
model.MasterPasswordHash,
|
model.MasterPasswordHash,
|
||||||
@ -110,7 +93,7 @@ namespace Bit.Api.Controllers
|
|||||||
model.Token,
|
model.Token,
|
||||||
ciphers,
|
ciphers,
|
||||||
folders,
|
folders,
|
||||||
null);
|
model.Data.PrivateKey);
|
||||||
|
|
||||||
if(result.Succeeded)
|
if(result.Succeeded)
|
||||||
{
|
{
|
||||||
@ -128,37 +111,23 @@ namespace Bit.Api.Controllers
|
|||||||
|
|
||||||
[HttpPut("password")]
|
[HttpPut("password")]
|
||||||
[HttpPost("password")]
|
[HttpPost("password")]
|
||||||
public async Task PutPassword([FromBody]PasswordRequestModel_Old model)
|
public async Task PutPassword([FromBody]PasswordRequestModel model)
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByPrincipalAsync(User);
|
var user = await _userService.GetUserByPrincipalAsync(User);
|
||||||
|
|
||||||
// NOTE: It is assumed that the eventual repository call will make sure the updated
|
// NOTE: It is assumed that the eventual repository call will make sure the updated
|
||||||
// ciphers belong to user making this call. Therefore, no check is done here.
|
// ciphers belong to user making this call. Therefore, no check is done here.
|
||||||
|
|
||||||
//var ciphers = model.Data.Ciphers.Select(c => c.ToCipher(user.Id));
|
var ciphers = model.Data.Ciphers.Select(c => c.ToCipher(user.Id));
|
||||||
//var folders = model.Data.Folders.Select(c => c.ToFolder(user.Id));
|
var folders = model.Data.Folders.Select(c => c.ToFolder(user.Id));
|
||||||
|
|
||||||
//var result = await _userService.ChangePasswordAsync(
|
|
||||||
// user,
|
|
||||||
// model.MasterPasswordHash,
|
|
||||||
// model.NewMasterPasswordHash,
|
|
||||||
// ciphers,
|
|
||||||
// folders,
|
|
||||||
// model.Data.PrivateKey);
|
|
||||||
|
|
||||||
//
|
|
||||||
// NOTE: Temporary backwards compat. Remove the below and uncomment the above whenever web vault v1.10.0 is released
|
|
||||||
//
|
|
||||||
|
|
||||||
var ciphers = model.Ciphers.Where(c => c.Type == CipherType.Login).Select(c => c.ToCipher(user.Id));
|
|
||||||
var folders = model.Ciphers.Where(c => c.Type == CipherType.Folder).Select(c => c.ToFolder(user.Id));
|
|
||||||
var result = await _userService.ChangePasswordAsync(
|
var result = await _userService.ChangePasswordAsync(
|
||||||
user,
|
user,
|
||||||
model.MasterPasswordHash,
|
model.MasterPasswordHash,
|
||||||
model.NewMasterPasswordHash,
|
model.NewMasterPasswordHash,
|
||||||
ciphers,
|
ciphers,
|
||||||
folders,
|
folders,
|
||||||
null);
|
model.Data.PrivateKey);
|
||||||
|
|
||||||
if(result.Succeeded)
|
if(result.Succeeded)
|
||||||
{
|
{
|
||||||
|
@ -20,23 +20,4 @@ namespace Bit.Core.Models.Api
|
|||||||
[Required]
|
[Required]
|
||||||
public DataReloadRequestModel Data { get; set; }
|
public DataReloadRequestModel Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public class EmailRequestModel_Old
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
[EmailAddress]
|
|
||||||
[StringLength(50)]
|
|
||||||
public string NewEmail { get; set; }
|
|
||||||
[Required]
|
|
||||||
[StringLength(300)]
|
|
||||||
public string MasterPasswordHash { get; set; }
|
|
||||||
[Required]
|
|
||||||
[StringLength(300)]
|
|
||||||
public string NewMasterPasswordHash { get; set; }
|
|
||||||
[Required]
|
|
||||||
public string Token { get; set; }
|
|
||||||
[Required]
|
|
||||||
public CipherRequestModel[] Ciphers { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,4 @@ namespace Bit.Core.Models.Api
|
|||||||
[Required]
|
[Required]
|
||||||
public DataReloadRequestModel Data { get; set; }
|
public DataReloadRequestModel Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public class PasswordRequestModel_Old
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
[StringLength(300)]
|
|
||||||
public string MasterPasswordHash { get; set; }
|
|
||||||
[Required]
|
|
||||||
[StringLength(300)]
|
|
||||||
public string NewMasterPasswordHash { get; set; }
|
|
||||||
[Required]
|
|
||||||
public CipherRequestModel[] Ciphers { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -59,17 +59,6 @@ namespace Bit.Core.Models.Api
|
|||||||
|
|
||||||
return existingCipher;
|
return existingCipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public Folder ToFolder(Guid userId)
|
|
||||||
{
|
|
||||||
return new Folder
|
|
||||||
{
|
|
||||||
Id = new Guid(Id),
|
|
||||||
UserId = userId,
|
|
||||||
Name = Name
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CipherShareRequestModel : IValidatableObject
|
public class CipherShareRequestModel : IValidatableObject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user