mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 14:53:19 +08:00
7263551aa8
## [Specify `Accept` header in registration request](https://github.com/ppy/osu/commit/28edb788f78723cda23281a8801acc2065592840) The lack of it meant that in specific scenarios web would respond with a chunk of HTML instead of JSON. ## [Allow showing registration error message even if no redirect is given](https://github.com/ppy/osu/commit/6ad49941ffd7cdf662ccd404836bb52fccec2142) There are scenarios where this can happen, and if it did, previously the strict requirement to have both would cause the specific message to be discarded and replaced with the generic "something happened" one.
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace osu.Game.Online.API
|
|
{
|
|
public class RegistrationRequest : OsuWebRequest
|
|
{
|
|
internal string Username = string.Empty;
|
|
internal string Email = string.Empty;
|
|
internal string Password = string.Empty;
|
|
|
|
protected override void PrePerform()
|
|
{
|
|
AddParameter(@"user[username]", Username);
|
|
AddParameter(@"user[user_email]", Email);
|
|
AddParameter(@"user[password]", Password);
|
|
|
|
AddHeader(@"Accept", @"application/json");
|
|
|
|
base.PrePerform();
|
|
}
|
|
|
|
public class RegistrationRequestErrors
|
|
{
|
|
/// <summary>
|
|
/// An optional error message.
|
|
/// </summary>
|
|
public string? Message;
|
|
|
|
/// <summary>
|
|
/// An optional URL which the user should be directed towards to complete registration.
|
|
/// </summary>
|
|
public string? Redirect;
|
|
|
|
public UserErrors? User;
|
|
|
|
public class UserErrors
|
|
{
|
|
[JsonProperty("username")]
|
|
public string[] Username = Array.Empty<string>();
|
|
|
|
[JsonProperty("user_email")]
|
|
public string[] Email = Array.Empty<string>();
|
|
|
|
[JsonProperty("password")]
|
|
public string[] Password = Array.Empty<string>();
|
|
}
|
|
}
|
|
}
|
|
}
|