-
Notifications
You must be signed in to change notification settings - Fork 10
.net task pr raised under new branch task3 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nangchetnamaw
wants to merge
13
commits into
cybergroupdevs:master
Choose a base branch
from
nangchetnamaw:task3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
01add55
final updation
nangchetnamaw 9a0a2fa
Changed html file name for the purpose of deployment
nangchetnamaw 47fac8d
Merge branch 'master' of https://github.com/nangchetnamaw/BootcampJan…
nangchetnamaw e081357
backend code added
nangchetnamaw 01da138
functionalities added
nangchetnamaw 521287e
claims added
nangchetnamaw 72c2ca0
ui added
nangchetnamaw f9b79b3
claims updated
nangchetnamaw 62624c2
missing file added
nangchetnamaw f80a85c
comments removed
nangchetnamaw 53412b7
comments removed
nangchetnamaw f5321c9
hard-coded connection string removed
nangchetnamaw 0c800ee
removed comments
nangchetnamaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+2.02 MB
Chetna_Mongmaw/UsersApplication/.vs/UsersApplication/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file added
BIN
+32 KB
Chetna_Mongmaw/UsersApplication/.vs/UsersApplication/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file added
BIN
+3.95 MB
Chetna_Mongmaw/UsersApplication/.vs/UsersApplication/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
984 changes: 984 additions & 0 deletions
984
Chetna_Mongmaw/UsersApplication/.vs/config/applicationhost.config
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,25 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio 15 | ||
| VisualStudioVersion = 15.0.28307.902 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsersApplication", "UsersApplication\UsersApplication.csproj", "{FDFFDA99-730C-4BD5-810A-898B460C41D1}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {FDFFDA99-730C-4BD5-810A-898B460C41D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {FDFFDA99-730C-4BD5-810A-898B460C41D1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {FDFFDA99-730C-4BD5-810A-898B460C41D1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {FDFFDA99-730C-4BD5-810A-898B460C41D1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {AF1D31B3-2427-4FBE-9F0F-2603C10ACFDB} | ||
| EndGlobalSection | ||
| EndGlobal |
82 changes: 82 additions & 0 deletions
82
Chetna_Mongmaw/UsersApplication/UsersApplication/Controllers/LoginController.cs
This file contains hidden or 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,82 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IdentityModel.Tokens.Jwt; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Web.Http.Cors; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.IdentityModel.Tokens; | ||
| using UsersApplication.Models; | ||
|
|
||
| namespace UsersApplication.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class LoginController : ControllerBase | ||
| { | ||
| private IConfiguration _config; | ||
| public Models.WebAppContext _webAppContext; | ||
|
|
||
| //[EnableCors("AllowSpecificOrigin")] | ||
| public LoginController(IConfiguration config, Models.WebAppContext context) | ||
| { | ||
| _config = config; | ||
| _webAppContext = context; | ||
| } | ||
| [AllowAnonymous] | ||
| [HttpPost] | ||
| public IActionResult Login([FromBody] Users login) | ||
| { | ||
| IActionResult response = Unauthorized(); | ||
| var user = AuthenticateUser(login); | ||
|
|
||
| if (user != null) | ||
| { | ||
| var tokenString = GenerateJSONWebToken(user); | ||
| response = Ok(new { token = tokenString }); | ||
| } | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| private string GenerateJSONWebToken(Users userInfo) | ||
| { | ||
| var claims = new[] { | ||
| new Claim(JwtRegisteredClaimNames.Email, userInfo.Email), | ||
| new Claim("Role", userInfo.Role), | ||
| new Claim("Username", userInfo.Username), | ||
| new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) | ||
| }; | ||
|
|
||
| var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); | ||
| var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); | ||
|
|
||
| var token = new JwtSecurityToken(_config["Jwt:Issuer"], | ||
| _config["Jwt:Issuer"], | ||
| claims, | ||
| expires: DateTime.Now.AddMinutes(120), | ||
| signingCredentials: credentials); | ||
|
|
||
| return new JwtSecurityTokenHandler().WriteToken(token); | ||
| } | ||
|
|
||
| private Users AuthenticateUser(Users login) | ||
| { | ||
| Users user = null; | ||
| try | ||
| { | ||
| user = _webAppContext.Users.Where(x => (x.Username == login.Username && x.Password == login.Password)).FirstOrDefault(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Console.WriteLine(e); | ||
| } | ||
| return user; | ||
| } | ||
| } | ||
| } | ||
|
|
55 changes: 55 additions & 0 deletions
55
Chetna_Mongmaw/UsersApplication/UsersApplication/Controllers/OperationsController.cs
This file contains hidden or 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,55 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using UsersApplication.Models; | ||
| using UsersApplication.CustomModels; | ||
| using UsersApplication.Repositories; | ||
|
|
||
| namespace UsersApplication.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class OperationsController : ControllerBase | ||
| { | ||
| Repositories.IRegister _reg; | ||
| public OperationsController(Repositories.IRegister reg) | ||
| { | ||
| _reg = reg; | ||
| } | ||
|
|
||
| [HttpPost] | ||
| public IActionResult Post([FromBody] UserInfo enteredDetails) | ||
| { | ||
| //Register register = new Register(enteredDetails); | ||
| //return Ok(userInfo); | ||
| var output = _reg.signupHandler(enteredDetails); | ||
|
|
||
| return Ok(output); | ||
| } | ||
| [HttpDelete("{id}")] | ||
| public IActionResult Delete([FromBody] deleteInfo toDelete) | ||
| { | ||
| var output = _reg.deleteHandler(toDelete); | ||
| return Ok(output); | ||
| } | ||
|
|
||
| [HttpPut("{id}")] | ||
| public IActionResult Put([FromBody] UserInfo updatedDetails) | ||
|
|
||
| { | ||
| var output = _reg.updateHandler(updatedDetails); | ||
| return Ok(output); | ||
| } | ||
|
|
||
| [HttpGet] | ||
| public IActionResult Get() | ||
| { | ||
| var output = _reg.listHandler(); | ||
| return Ok(output); | ||
|
|
||
| } | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
Chetna_Mongmaw/UsersApplication/UsersApplication/Controllers/ValuesController.cs
This file contains hidden or 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,45 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace UsersApplication.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class ValuesController : ControllerBase | ||
| { | ||
| // GET api/values | ||
| [HttpGet] | ||
| public ActionResult<IEnumerable<string>> Get() | ||
| { | ||
| return new string[] { "value1", "value2" }; | ||
| } | ||
|
|
||
| // GET api/values/5 | ||
| [HttpGet("{id}")] | ||
| public ActionResult<string> Get(int id) | ||
| { | ||
| return "value"; | ||
| } | ||
|
|
||
| // POST api/values | ||
| [HttpPost] | ||
| public void Post([FromBody] string value) | ||
| { | ||
| } | ||
|
|
||
| // PUT api/values/5 | ||
| [HttpPut("{id}")] | ||
| public void Put(int id, [FromBody] string value) | ||
| { | ||
| } | ||
|
|
||
| // DELETE api/values/5 | ||
| [HttpDelete("{id}")] | ||
| public void Delete(int id) | ||
| { | ||
| } | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
Chetna_Mongmaw/UsersApplication/UsersApplication/CustomModels/UserInfo.cs
This file contains hidden or 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,20 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using UsersApplication.Models; | ||
|
|
||
| namespace UsersApplication.CustomModels | ||
| { | ||
| public partial class UserInfo | ||
| { | ||
|
|
||
| public int RId { get; set; } | ||
| public string Name { get; set; } | ||
| public string Username { get; set; } | ||
| public string Email { get; set; } | ||
| public string Password { get; set; } | ||
| public int? ProjectId { get; set; } | ||
| public string Role { get; set; } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
Chetna_Mongmaw/UsersApplication/UsersApplication/CustomModels/deleteInfo.cs
This file contains hidden or 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,12 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace UsersApplication.CustomModels | ||
| { | ||
| public class deleteInfo | ||
| { | ||
| public int RId { get; set; } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
Chetna_Mongmaw/UsersApplication/UsersApplication/Models/Users.cs
This file contains hidden or 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,16 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace UsersApplication.Models | ||
| { | ||
| public partial class Users | ||
| { | ||
| public int RId { get; set; } | ||
| public string Name { get; set; } | ||
| public string Username { get; set; } | ||
| public string Email { get; set; } | ||
| public string Password { get; set; } | ||
| public int? ProjectId { get; set; } | ||
| public string Role { get; set; } | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
Chetna_Mongmaw/UsersApplication/UsersApplication/Models/WebAppContext.cs
This file contains hidden or 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,65 @@ | ||
| using System; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata; | ||
|
|
||
| namespace UsersApplication.Models | ||
| { | ||
| public partial class WebAppContext : DbContext | ||
| { | ||
| public WebAppContext() | ||
| { | ||
| } | ||
|
|
||
| public WebAppContext(DbContextOptions<WebAppContext> options) | ||
| : base(options) | ||
| { | ||
| } | ||
|
|
||
| public virtual DbSet<Users> Users { get; set; } | ||
|
|
||
| protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
| { | ||
| if (!optionsBuilder.IsConfigured) | ||
| { | ||
| #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings. | ||
| optionsBuilder.UseSqlServer("Server=CYG317\\SQLEXPRESS;Database=WebApp;Trusted_Connection=True;"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please Explain the use of this connection string
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrected |
||
| } | ||
| } | ||
|
|
||
| protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
| { | ||
| modelBuilder.Entity<Users>(entity => | ||
| { | ||
| entity.HasKey(e => e.RId); | ||
|
|
||
| entity.Property(e => e.RId).HasColumnName("R_id"); | ||
|
|
||
| entity.Property(e => e.Email) | ||
| .IsRequired() | ||
| .HasMaxLength(500) | ||
| .IsUnicode(false); | ||
|
|
||
| entity.Property(e => e.Name) | ||
| .IsRequired() | ||
| .HasMaxLength(500) | ||
| .IsUnicode(false); | ||
|
|
||
| entity.Property(e => e.Password) | ||
| .IsRequired() | ||
| .HasMaxLength(500) | ||
| .IsUnicode(false); | ||
|
|
||
| entity.Property(e => e.ProjectId).HasColumnName("ProjectID"); | ||
|
|
||
| entity.Property(e => e.Role) | ||
| .HasMaxLength(500) | ||
| .IsUnicode(false); | ||
|
|
||
| entity.Property(e => e.Username) | ||
| .IsRequired() | ||
| .HasMaxLength(500) | ||
| .IsUnicode(false); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
Chetna_Mongmaw/UsersApplication/UsersApplication/Program.cs
This file contains hidden or 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,24 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace UsersApplication | ||
| { | ||
| public class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| CreateWebHostBuilder(args).Build().Run(); | ||
| } | ||
|
|
||
| public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||
| WebHost.CreateDefaultBuilder(args) | ||
| .UseStartup<Startup>(); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
Chetna_Mongmaw/UsersApplication/UsersApplication/Properties/launchSettings.json
This file contains hidden or 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,30 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "iisSettings": { | ||
| "windowsAuthentication": false, | ||
| "anonymousAuthentication": true, | ||
| "iisExpress": { | ||
| "applicationUrl": "http://localhost:49801", | ||
| "sslPort": 44348 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "api/values", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "UsersApplication": { | ||
| "commandName": "Project", | ||
| "launchBrowser": true, | ||
| "launchUrl": "api/values", | ||
| "applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Unused Controller