aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline')
-rw-r--r--BackEnd/Timeline/Controllers/V2/SelfController.cs40
-rw-r--r--BackEnd/Timeline/Models/Http/HttpTimeline.cs9
-rw-r--r--BackEnd/Timeline/Models/Http/HttpTimelinePost.cs9
3 files changed, 52 insertions, 6 deletions
diff --git a/BackEnd/Timeline/Controllers/V2/SelfController.cs b/BackEnd/Timeline/Controllers/V2/SelfController.cs
new file mode 100644
index 00000000..1604bc67
--- /dev/null
+++ b/BackEnd/Timeline/Controllers/V2/SelfController.cs
@@ -0,0 +1,40 @@
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Timeline.Models.Http;
+using Timeline.Services.User;
+
+namespace Timeline.Controllers.V2
+{
+ [ApiController]
+ [Route("v2/self")]
+ public class SelfController : V2ControllerBase
+ {
+ private readonly IUserService _userService;
+
+ public SelfController(IUserService userService)
+ {
+ _userService = userService;
+ }
+
+ [HttpPost("changepassword")]
+ [Authorize]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status422UnprocessableEntity)]
+ public async Task<ActionResult> ChangePasswordAsync([FromBody] HttpChangePasswordRequest body)
+ {
+ try
+ {
+ await _userService.ChangePassword(GetAuthUserId(), body.OldPassword, body.NewPassword);
+ return NoContent();
+ }
+ catch (BadPasswordException)
+ {
+ return UnprocessableEntity(new ErrorResponse(ErrorResponse.InvalidRequest, "Old password is wrong."));
+ }
+ }
+ }
+}
+
diff --git a/BackEnd/Timeline/Models/Http/HttpTimeline.cs b/BackEnd/Timeline/Models/Http/HttpTimeline.cs
index 83398baf..401d84a2 100644
--- a/BackEnd/Timeline/Models/Http/HttpTimeline.cs
+++ b/BackEnd/Timeline/Models/Http/HttpTimeline.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
namespace Timeline.Models.Http
@@ -13,8 +13,10 @@ namespace Timeline.Models.Http
public HttpTimeline(string uniqueId, string title, string name, string nameV2, DateTime nameLastModifed, string description, HttpUser owner, TimelineVisibility visibility, List<HttpUser> members, string? color, DateTime createTime, DateTime lastModified, bool isHighlight, bool isBookmark, bool manageable, bool postable, HttpTimelineLinks links)
{
UniqueId = uniqueId;
- Title = title;
- Name = name;
+ Title = title;
+#pragma warning disable CS0618 // Type or member is obsolete
+ Name = name;
+#pragma warning restore CS0618 // Type or member is obsolete
NameV2 = nameV2;
NameLastModifed = nameLastModifed;
Description = description;
@@ -42,6 +44,7 @@ namespace Timeline.Models.Http
/// <summary>
/// Name of timeline.
/// </summary>
+ [Obsolete("Use NameV2")]
public string Name { get; set; } = default!;
/// <summary>
/// Name of timeline.
diff --git a/BackEnd/Timeline/Models/Http/HttpTimelinePost.cs b/BackEnd/Timeline/Models/Http/HttpTimelinePost.cs
index 5c6a7167..677c486f 100644
--- a/BackEnd/Timeline/Models/Http/HttpTimelinePost.cs
+++ b/BackEnd/Timeline/Models/Http/HttpTimelinePost.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
namespace Timeline.Models.Http
@@ -21,8 +21,10 @@ namespace Timeline.Models.Http
Color = color;
LastUpdated = lastUpdated;
TimelineOwnerV2 = timelineOwnerV2;
- TimelineNameV2 = timelineNameV2;
- TimelineName = timelineName;
+ TimelineNameV2 = timelineNameV2;
+#pragma warning disable CS0618 // Type or member is obsolete
+ TimelineName = timelineName;
+#pragma warning restore CS0618 // Type or member is obsolete
Editable = editable;
}
@@ -67,6 +69,7 @@ namespace Timeline.Models.Http
/// <summary>
/// Timeline name.
/// </summary>
+ [Obsolete("Use TimelineNameV2.")]
public string TimelineName { get; set; } = default!;
/// <summary>
/// True if you can edit this post.