Skip to content

Commit 153fb20

Browse files
committed
Fix return url in login and small cleanup in author model
1 parent 44618c3 commit 153fb20

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

src/App/Pages/Account/Login.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="form-login">
88
@if (!User.Identity.IsAuthenticated)
99
{
10-
<form asp-route-returnurl="@ViewData["ReturnUrl"]" class="form" method="POST">
10+
<form asp-route-returnurl="@HttpContext.Request.Query["ReturnUrl"]" class="form" method="POST">
1111
<div class="bf-account-header">
1212
<h1>Welcome!</h1>
1313
<p>You can sign in or go <a href="~/">back to blog</a>.</p>

src/App/Pages/Account/Login.cshtml.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Core.Data;
1+
using Core;
2+
using Core.Data;
23
using Microsoft.AspNetCore.Identity;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.AspNetCore.Mvc.RazorPages;
@@ -33,9 +34,8 @@ public void OnGet()
3334
{
3435
}
3536

36-
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
37+
public async Task<IActionResult> OnPostAsync([FromQuery]string returnUrl = null)
3738
{
38-
ViewData["ReturnUrl"] = returnUrl;
3939
if (ModelState.IsValid)
4040
{
4141
var result = await _sm.PasswordSignInAsync(UserName, Password, RememberMe, lockoutOnFailure: false);
@@ -54,6 +54,7 @@ public async Task<IActionResult> OnPostAsync(string returnUrl = null)
5454

5555
private IActionResult RedirectToLocal(string returnUrl)
5656
{
57+
returnUrl = returnUrl.SanitizePath();
5758
if (Url.IsLocalUrl(returnUrl))
5859
{
5960
return Redirect(returnUrl);

src/App/Views/Themes/material/List.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
</template>
125125
</span>
126126
</div>
127-
<h5 class="description">{{post.description}}</h5>
127+
<h5 class="description" v-html="post.description"></h5>
128128
<img v-bind:src="webRoot + post.cover" class="thumbnail col-sm-12 wp-post-image" alt="">
129129
<a href="#" class="btn btn-round btn-lg" style="margin-top: 25px">
130130
Read More

src/Core/Data/Domain/Author.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public Author() { }
1212
/// </summary>
1313
public int Id { get; set; }
1414

15-
[StringLength(160)]
16-
public string AppUserId { get; set; }
1715
[StringLength(160)]
1816
public string AppUserName { get; set; }
1917
[EmailAddress]

src/Core/Extensions/StringExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ static string RemoveExtraHyphen(string text)
214214

215215
public static string SanitizePath(this string str)
216216
{
217+
str = str.Replace("%2E", ".").Replace("%2F", "/");
218+
217219
if (str.Contains("..") || str.Contains("//"))
218220
throw new ApplicationException("Invalid directory path");
219221

@@ -222,7 +224,9 @@ public static string SanitizePath(this string str)
222224

223225
public static string SanitizeFileName(this string str)
224226
{
225-
if (str.Contains("..") || str.Contains("//") || str.Count(x => x == '.') > 1)
227+
str = str.SanitizePath();
228+
229+
if (str.Count(x => x == '.') > 1)
226230
throw new ApplicationException("Invalid file name");
227231

228232
return str;

0 commit comments

Comments
 (0)