-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Organizations]: UI for creating migration request #5241
Changes from all commits
5a02f4e
930abd4
552e728
c8978bb
8cba4dd
12df6a3
a881e1d
0e0ad2d
2924613
98445be
2d153fd
01e242b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,25 @@ public async Task<bool> ConfirmEmailAddress(User user, string token) | |
await UserRepository.CommitChangesAsync(); | ||
return true; | ||
} | ||
|
||
public async Task RequestTransformToOrganizationAccount(User accountToTransform, User adminUser) | ||
{ | ||
accountToTransform = accountToTransform ?? throw new ArgumentNullException(nameof(accountToTransform)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we handle the cases when the accountToTransform is already an organization ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's handled in UserService.CanTransformToOrganization |
||
adminUser = adminUser ?? throw new ArgumentNullException(nameof(adminUser)); | ||
|
||
// create new or update existing request | ||
if (accountToTransform.OrganizationMigrationRequest == null) | ||
{ | ||
accountToTransform.OrganizationMigrationRequest = new OrganizationMigrationRequest(); | ||
}; | ||
|
||
accountToTransform.OrganizationMigrationRequest.NewOrganization = accountToTransform; | ||
accountToTransform.OrganizationMigrationRequest.AdminUser = adminUser; | ||
accountToTransform.OrganizationMigrationRequest.ConfirmationToken = Crypto.GenerateToken(); | ||
accountToTransform.OrganizationMigrationRequest.RequestDate = DateTime.UtcNow; | ||
|
||
await UserRepository.CommitChangesAsync(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense as the requests to have a Status? Will they be ever completed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the confirmation logic is very similar to email confirmation. The user must be authenticated and verify against the token we generate. Nothing fancy is needed for status. We considered whether to expire the confirmation after 24hr, but chose to do the same as email confirmation which doesn't expire. We do store RequestDate in case we want to change this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add auditing for this scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there's a separate work item to track auditing which will be done at lower priority. |
||
} | ||
|
||
public bool CanTransformUserToOrganization(User accountToTransform, out string errorReason) | ||
{ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class TransformAccountViewModel | ||
{ | ||
[Required] | ||
[StringLength(255)] | ||
[Display(Name = "Administrator")] | ||
public string AdminUsername { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@model TransformAccountViewModel | ||
@{ | ||
ViewBag.Title = "Transform Account"; | ||
ViewBag.MdPageColumns = Constants.ColumnsFormMd; | ||
Layout = "~/Views/Shared/Gallery/Layout.cshtml"; | ||
} | ||
|
||
<section role="main" class="container main-container page-account-settings"> | ||
<div class="row"> | ||
<div class="@ViewHelpers.GetColumnClasses(ViewBag)"> | ||
<h1 class="text-center">Transform Account</h1> | ||
<div class="text-center ms-font-xxl"> | ||
<a href="@Url.User(CurrentUser)">@CurrentUser.Username</a> | ||
</div> | ||
|
||
<div> | ||
<aside class="col-md-3 col-md-push-9"> | ||
@Html.Label("Logo") | ||
@ViewHelpers.GravatarImage(CurrentUser.EmailAddress, CurrentUser.Username, Constants.GravatarImageSizeLarge, responsive: true) | ||
</aside> | ||
|
||
<div class="row form-group col-md-9 col-md-pull-3"> | ||
@Html.Label("Organization") | ||
<p>@CurrentUser.Username</p> | ||
</div> | ||
|
||
<div class="row form-group col-md-9 col-md-pull-3"> | ||
@Html.Label("Email") | ||
<p>@CurrentUser.EmailAddress</p> | ||
</div> | ||
|
||
@using (Html.BeginForm("Transform", "Users")) | ||
{ | ||
@Html.AntiForgeryToken() | ||
|
||
<div class="row form-group col-md-9 col-md-pull-3 @Html.HasErrorFor(m => m.AdminUsername)"> | ||
@Html.ShowLabelFor(m => m.AdminUsername) | ||
@Html.ShowTextBoxFor(m => m.AdminUsername) | ||
@Html.ShowValidationMessagesFor(m => m.AdminUsername) | ||
</div> | ||
|
||
<div class="row form-group"> | ||
<div class="col-md-6"> | ||
<input type="submit" class="btn btn-primary form-control" value="Transform" /> | ||
</div> | ||
<div class="col-md-6"> | ||
<a href="#" role="button" class="btn btn-default form-control" id="cancel-transform"> | ||
Cancel | ||
</a> | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</section> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the proposed admin requested to accept the request of becoming an admin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see PR #5228 for the confirmation
The proposed/pending organization admin must log in and confirm using the generated confirmationToken.