Added scrollboxes for Uploads/Pastets/Shortened Urls on the Profile.tags/2.0.3
@@ -111,6 +111,7 @@ namespace Teknik.Areas.Users.Controllers | |||
model.UserID = user.UserId; | |||
model.Username = user.Username; | |||
model.TrustedDeviceCount = user.TrustedDevices.Count; | |||
model.UserSettings = user.UserSettings; | |||
model.SecuritySettings = user.SecuritySettings; | |||
@@ -711,5 +712,40 @@ namespace Teknik.Areas.Users.Controllers | |||
Bitmap qrCodeImage = qrCode.GetGraphic(20); | |||
return File(Helpers.Utility.ImageToByte(qrCodeImage), "image/png"); | |||
} | |||
[HttpPost] | |||
public ActionResult ClearTrustedDevices() | |||
{ | |||
try | |||
{ | |||
User user = UserHelper.GetUser(db, User.Identity.Name); | |||
if (user != null) | |||
{ | |||
if (user.SecuritySettings.AllowTrustedDevices) | |||
{ | |||
// let's clear the trusted devices | |||
user.TrustedDevices.Clear(); | |||
List<TrustedDevice> foundDevices = db.TrustedDevices.Where(d => d.UserId == user.UserId).ToList(); | |||
if (foundDevices != null) | |||
{ | |||
foreach (TrustedDevice device in foundDevices) | |||
{ | |||
db.TrustedDevices.Remove(device); | |||
} | |||
} | |||
db.Entry(user).State = EntityState.Modified; | |||
db.SaveChanges(); | |||
return Json(new { result = true }); | |||
} | |||
return Json(new { error = "User does not allow trusted devices" }); | |||
} | |||
return Json(new { error = "User does not exist" }); | |||
} | |||
catch (Exception ex) | |||
{ | |||
return Json(new { error = ex.GetFullMessage(true) }); | |||
} | |||
} | |||
} | |||
} |
@@ -66,6 +66,32 @@ | |||
}); | |||
}); | |||
$('#ClearDevices').click(function () { | |||
$.ajax({ | |||
type: "POST", | |||
url: clearTrustedDevicesURL, | |||
data: {}, | |||
success: function (html) { | |||
if (html.result) { | |||
$('#ClearDevices').html('Clear Trusted Devices (0)'); | |||
$("#top_msg").css('display', 'inline', 'important'); | |||
$("#top_msg").html('<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Successfully Cleared Trusted Devices</div>'); | |||
} | |||
else { | |||
errorMsg = html; | |||
if (html.error) { | |||
errorMsg = html.error; | |||
if (html.error.message) { | |||
errorMsg = html.error.message; | |||
} | |||
} | |||
$("#top_msg").css('display', 'inline', 'important'); | |||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + errorMsg + '</div>'); | |||
} | |||
} | |||
}); | |||
}); | |||
$('#delete_account').click(function () { | |||
bootbox.confirm("Are you sure you want to delete your account?", function (result) { | |||
if (result) { |
@@ -13,6 +13,8 @@ namespace Teknik.Areas.Users.ViewModels | |||
public string Username { get; set; } | |||
public int TrustedDeviceCount { get; set; } | |||
public UserSettings UserSettings { get; set; } | |||
public SecuritySettings SecuritySettings { get; set; } |
@@ -117,7 +117,7 @@ | |||
</div><!--/tab-pane--> | |||
@if (OwnProfile) | |||
{ | |||
<div class="tab-pane" id="uploads"> | |||
<div class="tab-pane" id="uploads" style="overflow-y: auto; max-height: 500px;"> | |||
@foreach (Teknik.Areas.Upload.Models.Upload upload in Model.Uploads) | |||
{ | |||
<div class="panel panel-default"> | |||
@@ -149,7 +149,7 @@ | |||
</div> | |||
} | |||
</div><!--/tab-pane--> | |||
<div class="tab-pane" id="pastes"> | |||
<div class="tab-pane" id="pastes" style="overflow-y: auto; max-height: 500px;"> | |||
@foreach (Teknik.Areas.Paste.Models.Paste paste in Model.Pastes) | |||
{ | |||
<div class="panel panel-default"> | |||
@@ -188,7 +188,7 @@ | |||
</div> | |||
} | |||
</div> | |||
<div class="tab-pane" id="shortenedUrls"> | |||
<div class="tab-pane" id="shortenedUrls" style="overflow-y: auto; max-height: 500px;"> | |||
@foreach (Teknik.Areas.Shortener.Models.ShortenedUrl url in Model.ShortenedUrls) | |||
{ | |||
string shortUrl = Url.SubRouteUrl(string.Empty, "Shortener.View", new { url = url.ShortUrl }); |
@@ -8,6 +8,7 @@ | |||
var deleteUserURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "Delete" })'; | |||
var resendVerifyURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "ResendVerifyRecoveryEmail"})'; | |||
var confirmAuthSetupURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "VerifyAuthenticatorCode" })'; | |||
var clearTrustedDevicesURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "ClearTrustedDevices" })'; | |||
</script> | |||
@Styles.Render("~/Content/user") | |||
@@ -167,6 +168,9 @@ | |||
<input id="update_security_allow_trusted" name="update_security_allow_trusted" title="whether a device could be cached to bypass two factor authentication" type="checkbox" value="true" @(Model.SecuritySettings.AllowTrustedDevices ? "checked" : string.Empty) /> | |||
</label> | |||
</div> | |||
<p class="form-control-static @(Model.SecuritySettings.AllowTrustedDevices ? string.Empty : "hide")" id="ClearDevicesLink"> | |||
<small><a href="#" class="text-primary" id="ClearDevices">Clear Trusted Devices (@Model.TrustedDeviceCount)</a></small> | |||
</p> | |||
</div> | |||
</div> | |||
</div> |