minor fixes

This commit is contained in:
2017-02-02 11:37:14 +02:00
parent 53b5a7547b
commit 2cdc6a54b3
5 changed files with 16 additions and 9 deletions
@@ -61,7 +61,11 @@ export class ProfileComponent implements OnInit {
} }
else { else {
//notify something not OK //notify something not OK
this.showToast({ title: "Password change error", body: data.errors, type: ToastType.error }); if (!data.isLoggedIn) {
localStorage.removeItem("user");
this._router.navigate(['/']);//to default or last url
}
this.showToast({ title: "Password change error", body: data.errors.map(err => err.description), type: ToastType.error });
} }
}, err => { }, err => {
this.log.error(err); this.log.error(err);
@@ -14,6 +14,7 @@ export class User {
email: string; email: string;
password: string; password: string;
newpassword: string; newpassword: string;
isLoggedIn: boolean;
isAdmin: boolean; isAdmin: boolean;
succeeded: boolean; succeeded: boolean;
isLockedOut: boolean; isLockedOut: boolean;
@@ -5,7 +5,6 @@ import { AppModule } from './app/app.module';
import * as $ from 'jquery'; import * as $ from 'jquery';
import 'bootstrap'; import 'bootstrap';
//import { AppInsightsModule, AppInsightsService } from 'ng2-appinsights';
// Enable either Hot Module Reloading or production mode // Enable either Hot Module Reloading or production mode
if (module['hot']) { if (module['hot']) {
@@ -23,8 +22,3 @@ if (document.readyState === 'complete') {
} else { } else {
document.addEventListener('DOMContentLoaded', bootApplication); document.addEventListener('DOMContentLoaded', bootApplication);
} }
//var appIns: AppInsightsService = new AppInsightsService('');
//appIns.Init({
// instrumentationKey: '9f667285-ff2c-4626-a8da-1db518593323' //TODO - MOVE INTO A CONFIG FILE THAT SHOULD NOT BE COMMITED
//});
@@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LanBackup.WebApp.Models.Telemetry; using LanBackup.WebApp.Models.Telemetry;
using System.Net;
namespace LanBackup.WebApp.Controllers namespace LanBackup.WebApp.Controllers
{ {
@@ -146,6 +145,7 @@ namespace LanBackup.WebApp.Controllers
if (user != null) if (user != null)
{ {
dtouser.Succeeded = false; dtouser.Succeeded = false;
dtouser.IsLoggedIn = true;
var result = await _userManager.ChangePasswordAsync(user, dtouser.Password, dtouser.NewPassword); var result = await _userManager.ChangePasswordAsync(user, dtouser.Password, dtouser.NewPassword);
if (result.Succeeded) if (result.Succeeded)
{ {
@@ -162,7 +162,14 @@ namespace LanBackup.WebApp.Controllers
return BadRequest(msg); return BadRequest(msg);
} }
} }
return StatusCode((int)HttpStatusCode.Unauthorized, "User not logged in");// Unauthorized(); else
{
this.telemetry.TrackEvent("ChangePasswordNotLoggedIn");
dtouser.Succeeded = false;
dtouser.IsLoggedIn = false;
dtouser.Errors = new IdentityError[] { new IdentityError() { Description = "User not logged in" } };
return Ok(dtouser);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
+1
View File
@@ -10,6 +10,7 @@ namespace LanBackup.WebApp.Models
public string Email { get; set; } public string Email { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string NewPassword { get; set; } public string NewPassword { get; set; }
public bool IsLoggedIn { get; set; }
public bool IsAdmin { get; set; } public bool IsAdmin { get; set; }
public bool Succeeded { get; set; } public bool Succeeded { get; set; }
public bool IsLockedOut { get; set; } public bool IsLockedOut { get; set; }