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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var game = Game.CreateGame(); | |
game.StartGame(); | |
Debug.WriteLine("Text here"); | |
} | |
} |
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
version: '3.1' | |
services: | |
elasticsearch: | |
container_name: elasticsearch | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.2 | |
ports: | |
- 9200:9200 | |
volumes: |
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
"RateLimitOptions": { | |
"ClientWhitelist": [], | |
"EnableRateLimiting": true, | |
"Period": "1s", | |
"PeriodTimespan": 1, | |
"Limit": 1 | |
}, |
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
{ | |
"Routes": [ | |
//product api config | |
{ | |
"DownstreamPathTemplate": "/api/product/{everything}", | |
"DownstreamScheme": "https", | |
"DownstreamHostAndPorts": [ | |
{ | |
"Host": "localhost", | |
"Port": 44336 |
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
using Microsoft.Extensions.DependencyInjection; | |
using MusicMarket.Api.Settings; | |
using Microsoft.AspNetCore.Authentication.JwtBearer; | |
using Microsoft.IdentityModel.Tokens; | |
using System.Text; | |
using System; | |
using Microsoft.AspNetCore.Builder; | |
namespace MusicMarket.Api.Extensions | |
{ |
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
private string GenerateJwt(User user, IList<string> roles) | |
{ | |
var claims = new List<Claim> | |
{ | |
new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()), | |
new Claim(ClaimTypes.Name, user.UserName), | |
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), | |
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()) | |
}; |
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
[HttpPost("User/{userEmail}/Role")] | |
public async Task<IActionResult> AddUserToRole(string userEmail, [FromBody] string roleName) | |
{ | |
var user = _userManager.Users.SingleOrDefault(u => u.UserName == userEmail); | |
var result = await _userManager.AddToRoleAsync(user, roleName); | |
if (result.Succeeded) | |
{ | |
return Ok(); |
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
[HttpPost("Roles")] | |
public async Task<IActionResult> CreateRole(string roleName) | |
{ | |
if(string.IsNullOrWhiteSpace(roleName)) | |
{ | |
return BadRequest("Role name should be provided."); | |
} | |
var newRole = new Role | |
{ |
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
[HttpPost("SignIn")] | |
public async Task<IActionResult> SignIn(UserLoginDTO userLoginDto) | |
{ | |
var user = _userManager.Users.SingleOrDefault(u => u.UserName == userLoginDto.Email); | |
if (user is null) | |
{ | |
return NotFound("User not found"); | |
} | |
var userSigninResult = await _userManager.CheckPasswordAsync(user, userLoginDto.Password); |
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
namespace MyMusic.Api.Resources | |
{ | |
public class UserLoginDTO | |
{ | |
public string Email { get; set; } | |
public string Password { get; set; } | |
} | |
} |
NewerOlder