Skip to content

Commit

Permalink
#2 - If user type name with spaces he'll get error
Browse files Browse the repository at this point in the history
  • Loading branch information
pixellos committed Oct 1, 2016
1 parent f21d854 commit 5765335
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 11 deletions.
5 changes: 2 additions & 3 deletions WebLedMatrix.Matrix/Logic/ServiceWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ public void SetName(string name)
try
{
_client.UnRegisterMatrix(_name);
_name = name;
_client.RegisterMatrix(_name);
}
catch (Exception )
{
//Connection has been lost
}

_name = name;
_client.RegisterMatrix(_name);
}
}
}
3 changes: 2 additions & 1 deletion WebLedMatrix.Matrix/OutputWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Window x:Class="WebLedMatrix.Matrix.OutputWindow"
<Window WindowStyle="None" WindowState="Maximized" WindowStartupLocation="CenterOwner" x:Class="WebLedMatrix.Matrix.OutputWindow"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
5 changes: 5 additions & 0 deletions WebLedMatrix.Matrix/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public MainViewModel(IDataService dataService)
_serviceWrapper = IoCContainter.Resolve<ServiceWrapper>();
SetName = new RelayCommand(() =>
{
if (NodeName.Contains(" "))
{
MessageBox.Show("Name cannot contain spaces", "Error!");
return;
}
_serviceWrapper.SetName(NodeName);
Messenger.Default.Send(new NotificationMessage(MessageStrings.Show));
});
Expand Down
2 changes: 0 additions & 2 deletions WebLedMatrix/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ public PartialViewResult Login(LoginModel loginModel)
{
if (HttpContext.User.Identity.IsAuthenticated)
return PartialView("Greetings", User.Identity.Name);

if (ModelState.IsValid && Manager.TryLogin(loginModel))
return PartialView("AccessGranted");

ModelState.AddModelError(string.Empty,"Input incorrect data");

return PartialView(loginModel);
Expand Down
4 changes: 4 additions & 0 deletions WebLedMatrix/Controllers/Authentication/Abstract/ITwinUser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using WebLedMatrix.Logic.Authentication.Models.Roles;

namespace WebLedMatrix.Logic.Authentication.Abstract
{
Expand All @@ -12,5 +13,8 @@ public interface ITwinUser

[Required]
string TelephoneNumber { get; set; }

[Required]
string About { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ namespace WebLedMatrix.Logic.Authentication.Infrastructure
{
public class UserIdentityDbContext : IdentityDbContext<User>
{
public UserIdentityDbContext() : base("Server=tcp:data11admin.database.windows.net,1433;Database=TestDatabase;User ID=admin1@data11admin;Password=Data123456!;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;") {}

public UserIdentityDbContext(): base("Server=tcp:data11admin.database.windows.net,1433;Initial Catalog=TestDatabase;Persist Security Info=False;User ID=admin1@data11admin;Password=Data123456!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;")
{

}
static UserIdentityDbContext()
{
System.Data.Entity.Database.SetInitializer<UserIdentityDbContext>(new UserIdentityDbInitialize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protected override void Seed(UserIdentityDbContext context)
base.Seed(context);
}

private string userName = "Admin";
private string password = "ChangeThisPassword1";
private string userName = "Administrator";
private string password = "Admin1";
private string email = "[email protected]";
private string firstName = "TWIN";
private string lastName= "TWIN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public class CreationModel : ITwinUser
public string LastName { get; set; }
[Required]
public string TelephoneNumber { get; set; }
[Required]
public string About { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace WebLedMatrix.Logic.Authentication.Models.Roles
{
enum TypicalRoles
public enum TypicalRoles
{
User,
Speaker,
Expand Down
31 changes: 31 additions & 0 deletions WebLedMatrix/Migrations/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace WebLedMatrix.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;

internal sealed class Configuration : DbMigrationsConfiguration<WebLedMatrix.Logic.Authentication.Infrastructure.UserIdentityDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}

protected override void Seed(WebLedMatrix.Logic.Authentication.Infrastructure.UserIdentityDbContext context)
{
// This method will be called after migrating to the latest version.

// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
}
}
}
1 change: 1 addition & 0 deletions WebLedMatrix/Models/AdministrationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class AdministrationModel
{
public string Id { get; set; }
public string Name { get; set; }
public int Value { get; set; }
}
}
1 change: 1 addition & 0 deletions WebLedMatrix/WebLedMatrix.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<Compile Include="Controllers\Authentication\Concrete\DefaultUserValidatorHelper.cs" />
<Compile Include="Controllers\Authentication\Concrete\ResultException.cs" />
<Compile Include="Logic\HubConnections.cs" />
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\AdministrationModel.cs" />
<Compile Include="Models\Authentication\Roles\RoleAdministrating.cs" />
<Compile Include="Models\HubUser.cs" />
Expand Down

0 comments on commit 5765335

Please sign in to comment.