-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
220a93e
commit 6e45404
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using AnalysisData.Data; | ||
using AnalysisData.Repository.UserRepository.Abstraction; | ||
using AnalysisData.UserManage.LoginModel; | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AnalysisData.Services; | ||
|
||
public class UserService : ControllerBase | ||
{ | ||
private readonly IUserRepository _userRepository; | ||
|
||
public UserService(IUserRepository userRepository) | ||
{ | ||
_userRepository = userRepository; | ||
} | ||
public async Task<IActionResult> Login([FromBody] UserLoginModel userLoginModel) | ||
{ | ||
var user = await _userRepository.GetUser(userLoginModel.userName); | ||
if (user is null) | ||
{ | ||
return NotFound($"Unable to load user with username '{userLoginModel.userName}'"); | ||
} | ||
|
||
if (user.Password != userLoginModel.password) | ||
{ | ||
return Unauthorized("Invalid username or password."); | ||
} | ||
|
||
return Ok(new | ||
{ | ||
Massage = "welcome", | ||
Token = "سشی" | ||
}); | ||
|
||
|
||
|
||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
AnalysisData/AnalysisData/UserManage/LoginModel/UserLoginModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace AnalysisData.UserManage.LoginModel; | ||
|
||
public class UserLoginModel | ||
{ | ||
public string userName { get; set; } | ||
public string password { get; set; } | ||
public bool rememberMe { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.0", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": true | ||
} | ||
|