Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab397bb

Browse files
Merge pull request #23 from livealvi/auth
Auth
2 parents 4153d38 + 8843592 commit ab397bb

File tree

21 files changed

+253
-221
lines changed

21 files changed

+253
-221
lines changed

‎BusinessEntityLayer/BusinessEntityLayer.csproj‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</ItemGroup>
4646
<ItemGroup>
4747
<Compile Include="ArchiveModel.cs" />
48-
<Compile Include="AuthModel.cs" />
48+
<Compile Include="TokenModel.cs" />
4949
<Compile Include="CategoryModel.cs" />
5050
<Compile Include="ExpansModel.cs" />
5151
<Compile Include="FeaturedVideoModel.cs" />
@@ -55,7 +55,6 @@
5555
<Compile Include="Properties\AssemblyInfo.cs" />
5656
<Compile Include="SalaryModel.cs" />
5757
<Compile Include="SubscriptionModel.cs" />
58-
<Compile Include="UserAuthModel.cs" />
5958
<Compile Include="UserModel.cs" />
6059
<Compile Include="VideoModel.cs" />
6160
</ItemGroup>

‎BusinessEntityLayer/AuthModel.cs‎ renamed to ‎BusinessEntityLayer/TokenModel.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
namespace BusinessEntityLayer
88
{
9-
public class AuthModel
9+
public class TokenModel
1010
{
1111
public int Id { get; set; }
12-
public string Token { get; set; }
12+
public string TokenData { get; set; }
1313
public string Device { get; set; }
1414
public string Platfrom { get; set; }
1515
public string Browser { get; set; }
@@ -20,7 +20,6 @@ public class AuthModel
2020
public Nullable<int> LoginId { get; set; }
2121
public Nullable<int> UserId { get; set; }
2222

23-
public virtual UserModel User { get; set; }
2423
public virtual LoginModel Login { get; set; }
2524
}
2625
}

‎BusinessEntityLayer/UserAuthModel.cs‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎BusinessLogicLayer/BusinessLogicLayer.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<Reference Include="System.Xml" />
4545
</ItemGroup>
4646
<ItemGroup>
47+
<Compile Include="Services\AuthService.cs" />
4748
<Compile Include="Services\LoginService.cs" />
4849
<Compile Include="Services\CategoryService.cs" />
4950
<Compile Include="Services\ExpansService.cs" />
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using AutoMapper;
2+
using BusinessEntityLayer;
3+
using DataAccessLayer;
4+
using DataAccessLayer.EntityFramework;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace BusinessLogicLayer.Services
12+
{
13+
public class AuthService
14+
{
15+
16+
public static void Authenticate(LoginModel login)
17+
{
18+
var tokenModel = new TokenModel();
19+
var config = new MapperConfiguration(c => c.CreateMap<LoginModel, Login>());
20+
var mapper = new Mapper(config);
21+
var data = mapper.Map<LoginModel, Login>(login);
22+
var result = DataAccessFactory.AuthDataAccess().Authenticate(data);
23+
24+
if (result != null)
25+
{
26+
tokenModel.TokenData = result.TokenData;
27+
tokenModel.LoginId = result.LoginId;
28+
}
29+
if (result == null)
30+
{
31+
throw new Exception("User not found");
32+
}
33+
}
34+
35+
public static LoginModel EmailCheck(string email)
36+
{
37+
var config = new MapperConfiguration(c =>
38+
{
39+
c.CreateMap<Login, LoginModel>();
40+
});
41+
var mapper = new Mapper(config);
42+
var isFind = mapper.Map<Login, LoginModel>(DataAccessFactory.AuthDataAccess().GetByEmail(email));
43+
return isFind;
44+
}
45+
}
46+
}

‎BusinessLogicLayer/Services/LoginService.cs‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,6 @@ namespace BusinessLogicLayer.Services
1313
{
1414
public class LoginService
1515
{
16-
17-
public static void Authenticate(LoginModel login)
18-
{
19-
var authModel = new AuthModel();
20-
var config = new MapperConfiguration(c => c.CreateMap<LoginModel,Login>());
21-
var mapper = new Mapper(config);
22-
var data = mapper.Map<LoginModel, Login>(login);
23-
var result = DataAccessFactory.AuthDataAccess().Authenticate(data);
24-
25-
if (result != null)
26-
{
27-
authModel.Token = result.Token;
28-
authModel.LoginId = result.LoginId;
29-
}
30-
if (result == null)
31-
{
32-
throw new Exception("User not found");
33-
}
34-
}
35-
3616
public static void Create(LoginModel login)
3717
{
3818
login.Role = "User";

‎DataAccessLayer/App.Config‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
1111
</providers>
1212
</entityFramework>
13-
&gt;<connectionStrings><add name="WebSeriesDBEntities" connectionString="metadata=res://*/EntityFramework.WebSeriesDB.csdl|res://*/EntityFramework.WebSeriesDB.ssdl|res://*/EntityFramework.WebSeriesDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=web-series.database.windows.net;initial catalog=WebSeriesDB;user id=livealvi;password=Highme1#;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration>
13+
<connectionStrings><add name="WebSeriesDBEntities" connectionString="metadata=res://*/EntityFramework.WebSeriesDB.csdl|res://*/EntityFramework.WebSeriesDB.ssdl|res://*/EntityFramework.WebSeriesDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=web-series.database.windows.net;initial catalog=WebSeriesDB;user id=livealvi;password=Highme1#;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration>

‎DataAccessLayer/DataAccessFactory.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public static IRepository<Login, int> LoginDataAccess()
3535
{
3636
return new LoginRepo(db);
3737
}
38-
public static IAuth AuthDataAccess()
38+
public static IAuth<Login,string> AuthDataAccess()
3939
{
40-
return new LoginRepo(db);
40+
return new AuthRepo(db);
4141
}
4242

4343
//User

‎DataAccessLayer/DataAccessLayer.csproj‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858
<Compile Include="EntityFramework\Archive.cs">
5959
<DependentUpon>WebSeriesDB.tt</DependentUpon>
6060
</Compile>
61-
<Compile Include="EntityFramework\Auth.cs">
62-
<DependentUpon>WebSeriesDB.tt</DependentUpon>
63-
</Compile>
6461
<Compile Include="EntityFramework\Category.cs">
6562
<DependentUpon>WebSeriesDB.tt</DependentUpon>
6663
</Compile>
@@ -88,6 +85,9 @@
8885
<Compile Include="EntityFramework\Subscription.cs">
8986
<DependentUpon>WebSeriesDB.tt</DependentUpon>
9087
</Compile>
88+
<Compile Include="EntityFramework\Token.cs">
89+
<DependentUpon>WebSeriesDB.tt</DependentUpon>
90+
</Compile>
9191
<Compile Include="EntityFramework\User.cs">
9292
<DependentUpon>WebSeriesDB.tt</DependentUpon>
9393
</Compile>
@@ -103,8 +103,8 @@
103103
<DependentUpon>WebSeriesDB.Context.tt</DependentUpon>
104104
</Compile>
105105
<Compile Include="EntityFramework\WebSeriesDB.cs">
106-
<AutoGen>True</AutoGen>
107106
<DesignTime>True</DesignTime>
107+
<AutoGen>True</AutoGen>
108108
<DependentUpon>WebSeriesDB.tt</DependentUpon>
109109
</Compile>
110110
<Compile Include="EntityFramework\WebSeriesDB.Designer.cs">
@@ -119,6 +119,7 @@
119119
<Compile Include="Interfaces\ISubscription.cs" />
120120
<Compile Include="Interfaces\IWatch.cs" />
121121
<Compile Include="Repo\AuthRepo.cs" />
122+
<Compile Include="Repo\TokenRepo.cs" />
122123
<Compile Include="Repo\CategoryRepo.cs" />
123124
<Compile Include="Repo\ExpansRepo.cs" />
124125
<Compile Include="Repo\FeaturedVideoRepo.cs" />

‎DataAccessLayer/EntityFramework/Login.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public partial class Login
1717
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
1818
public Login()
1919
{
20-
this.Auths = new HashSet<Auth>();
20+
this.Tokens = new HashSet<Token>();
2121
this.Users = new HashSet<User>();
2222
}
2323

@@ -28,7 +28,7 @@ public Login()
2828
public string Role { get; set; }
2929

3030
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
31-
public virtual ICollection<Auth>Auths { get; set; }
31+
public virtual ICollection<Token>Tokens { get; set; }
3232
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
3333
public virtual ICollection<User> Users { get; set; }
3434
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /