Skip to content
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

Merged
merged 12 commits into from
Jan 9, 2018

Conversation

chenriksson
Copy link
Member

@chenriksson chenriksson commented Jan 5, 2018

Screenshot, when request already created (will overwrite):
image

Screenshot, when admin is not found:
image

@agr
Copy link
Contributor

agr commented Jan 8, 2018

Was using the word "Transform" discussed? I have a feeling "Convert" would be more appropriate here. As in "Convert to organization account".

[Authorize]
public virtual ActionResult Transform()
{
var accountToTransform = GetCurrentUser();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null check for accountToTransform?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Authorize attribute should ensure that there is an authenticated user.


public async Task RequestTransformToOrganizationAccount(User accountToTransform, User adminUser)
{
accountToTransform = accountToTransform ?? throw new ArgumentNullException(nameof(accountToTransform));
Copy link
Contributor

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?

Copy link
Member Author

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.


public async Task RequestTransformToOrganizationAccount(User accountToTransform, User adminUser)
{
accountToTransform = accountToTransform ?? throw new ArgumentNullException(nameof(accountToTransform));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we handle the cases when the accountToTransform is already an organization ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accountToTransform.OrganizationMigrationRequest.ConfirmationToken = Crypto.GenerateToken();
accountToTransform.OrganizationMigrationRequest.RequestDate = DateTime.UtcNow;

await UserRepository.CommitChangesAsync();
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

accountToTransform.OrganizationMigrationRequest.ConfirmationToken = Crypto.GenerateToken();
accountToTransform.OrganizationMigrationRequest.RequestDate = DateTime.UtcNow;

await UserRepository.CommitChangesAsync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add auditing for this scenario?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@cristinamanum cristinamanum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - few comments.

@chenriksson
Copy link
Member Author

@agr "Transform" comes from the PM spec, and also matches the terminology used by GitHub.

@chenriksson chenriksson changed the title [Organiations]: UI for creating migration request [Organizations]: UI for creating migration request Jan 8, 2018
<value>Administrator account '{0}' does not exist.</value>
</data>
<data name="TransformAccount_AdminAccountNotConfirmed" xml:space="preserve">
<value>Administrator account '{0}' has not validated their email address.</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use "confirmed" instead of "validated" for this message because that's how it appears elsewhere on the site

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I chose 'validated' instead of 'confirmed' because I thought it was consistent with other strings. Will try to be consistent and run any messages by @anangaur.

<div>
<aside class="col-md-3 col-md-push-9">
@Html.Label("Logo")
@ViewHelpers.GravatarImage(CurrentUser.EmailAddress, CurrentUser.Username, 332, responsive: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple thoughts--
1 - I noticed 332 was what we also used on the profile page. Can we put this in a constant of some sort?
2 - Make sure you check how this looks on smaller screens.


<div class="row form-group col-md-9 col-md-pull-3">
@Html.Label("Organization")
@Html.ShowTextBoxFor(m => CurrentUser.Username, enabled: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look odd as disabled textboxes, especially given that it makes the text harder to see. Can we do what we have in the verify form for these uneditable fields?

E.g.
image

}

[Fact]
public async Task Post_CanTransformReturnsFalse_ShowsError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i recommend splitting the Get and Post into separate classes and creating a base for the shared logic.

E.g.

public class TheTransformActions : TestContainer
{
    protected UsersController CreateController(string accountToTransform, string canTransformErrorReason = "")
    {
        ...
    }
}

public class TheGetTransformAction : TheTransformActions
{
    ...
}

public class ThePostTransformAction : TheTransformActions
{
    ...
}

for (int i = 0; i < (testOverwrite ? 2 : 1); i++)
{
// Act
await service.RequestTransformToOrganizationAccount(account, admin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may make this test stronger if, for the rewrite test, a different admin user was used

for example, if there was a bug that didn't set the admin of the request to the new admin but still succeeded the request, this test would return a false negative

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


[HttpGet]
[Authorize]
public virtual ActionResult Transform()
Copy link
Contributor

@scottbommarito scottbommarito Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional thing I noticed--I think something like TransformAccountToOrganization would be more descriptive and potentially a better name for this action.

@chenriksson chenriksson changed the base branch from chenriks-org-transform to dev January 9, 2018 22:17
@chenriksson
Copy link
Member Author

@scottbommarito new screenshot below -

image

@scottbommarito
Copy link
Contributor

@chenriksson Looks much better! Great work!

@chenriksson chenriksson merged commit 90e8ada into dev Jan 9, 2018
@chenriksson chenriksson deleted the chenriks-org-transform-ui branch January 9, 2018 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants