Fix IoC
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using AutoMapper;
|
||||
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using skydiveLogs_api.Settings;
|
||||
|
||||
using System;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
@@ -22,6 +19,8 @@ namespace skydiveLogs_api.Controllers
|
||||
[ApiController]
|
||||
public class UserController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserController(IUserService userService,
|
||||
IMapper mapper,
|
||||
IOptions<JwtSettings> jwtSettings)
|
||||
@@ -31,6 +30,10 @@ namespace skydiveLogs_api.Controllers
|
||||
_jwtConf = jwtSettings.Value;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// GET: api/User/AlwayLogin
|
||||
[HttpGet("AlwaysLogin")]
|
||||
[EnableCors]
|
||||
@@ -39,7 +42,6 @@ namespace skydiveLogs_api.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
// POST: api/User/Authenticate
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Authenticate")]
|
||||
@@ -90,6 +92,8 @@ namespace skydiveLogs_api.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
// PUT: api/User/5
|
||||
//[HttpPut("{id}")]
|
||||
//[EnableCors]
|
||||
@@ -98,6 +102,8 @@ namespace skydiveLogs_api.Controllers
|
||||
// _userService.UpdateUser(id, _mapper.Map<User>(value));
|
||||
//}
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string CreateToken(UserResp foundUser)
|
||||
{
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtConf.Passphrase));
|
||||
@@ -118,8 +124,14 @@ namespace skydiveLogs_api.Controllers
|
||||
return new JwtSecurityTokenHandler().WriteToken(token);
|
||||
}
|
||||
|
||||
private readonly IUserService _userService;
|
||||
private readonly IMapper _mapper;
|
||||
#endregion Private Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly JwtSettings _jwtConf;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user