Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5b51132
JwtBearer nuget
MrMehmet Feb 11, 2023
3e3a19c
controllers
MrMehmet Feb 11, 2023
e2227c6
user controller
MrMehmet Feb 11, 2023
a3ce56d
auth,role,user services
MrMehmet Feb 11, 2023
341ce5c
other services
MrMehmet Feb 11, 2023
fbfc71c
roles query
MrMehmet Feb 11, 2023
d12a4b1
roles commands
MrMehmet Feb 11, 2023
0f62f5d
users query
MrMehmet Feb 11, 2023
102b295
identity
MrMehmet Feb 11, 2023
efe2f25
abstractions
MrMehmet Feb 11, 2023
478e2c6
DTOs
MrMehmet Feb 11, 2023
a853f3e
exceptions
MrMehmet Feb 11, 2023
b44bd4c
users commands
MrMehmet Feb 11, 2023
8437bb3
AuthorizeDefinitionAttribute
MrMehmet Feb 11, 2023
57352b0
endpoints
MrMehmet Feb 11, 2023
f6a3dd7
Merge branch 'feature-clean-edit' of https://github.com/Hypance/HyBe …
MrMehmet Feb 11, 2023
553627d
controllers updated
MrMehmet Feb 24, 2023
ee023f6
Abstractions updated
MrMehmet Feb 24, 2023
74fae69
CustomAttributes updated
MrMehmet Feb 24, 2023
37c21b3
DTO's updated
MrMehmet Feb 24, 2023
532ad21
Exceptions updated
MrMehmet Feb 24, 2023
0ec6c47
fix v1
Memo-Lee Mar 2, 2023
c44de75
Merge branch 'feature-clean-edit' of https://github.com/Hypance/HyBe …
Memo-Lee Mar 2, 2023
f5802f3
Merge branch 'feature-clean-edit' into feature-authentication
Memo-Lee Mar 15, 2023
c035161
package updated
Memo-Lee Mar 15, 2023
24cd9df
project working
Memo-Lee Mar 15, 2023
6f8ff10
mediatr bug
Memo-Lee Mar 16, 2023
190a5f5
Added user process
Memo-Lee Mar 18, 2023
82d1bcc
added authentication
Memo-Lee Mar 18, 2023
719dcd2
Fixed Authantication
suhakesikbas Mar 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HyBe.Application.Abstractions.Services.Authentications
{
public interface IInternalAuthentication
{
Task<DTOs.Token> LoginAsync(string usernameOrEmail, string password);
Task<DTOs.Token> RefreshTokenLoginAsync(string refreshToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions Core/HyBe.Application/Abstractions/Services/IAuthService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HyBe.Application.Abstractions.Services.Authentications;

namespace HyBe.Application.Abstractions.Services
{
public interface IAuthService : IInternalAuthentication
{
Task PasswordResetAsnyc(string email);
Task<bool> VerifyResetTokenAsync(string resetToken, string userId);
}
}
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions Core/HyBe.Application/Abstractions/Services/IUserService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using HyBe.Application.DTOs.User;
using HyBe.Domain.Entities.Identity;

namespace HyBe.Application.Abstractions.Services
{
public interface IUserService
{
Task<CreateUserResponse> CreateAsync(CreateUser model);
Task UpdateRefreshTokenAsync(string refreshToken, AppUser user, DateTime accessTokenDate, int addOnAccessTokenDate);
}
}
10 changes: 10 additions & 0 deletions Core/HyBe.Application/Abstractions/Token/ITokenHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using HyBe.Domain.Entities.Identity;

namespace HyBe.Application.Abstractions.Token
{
public interface ITokenHandler
{
DTOs.Token CreateAccessToken(AppUser appUser);
string CreateRefreshToken();
}
}
Empty file.
Empty file.
1 change: 1 addition & 0 deletions Core/HyBe.Application/DTOs/Configuration/Menu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

14 changes: 14 additions & 0 deletions Core/HyBe.Application/DTOs/Token.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.DTOs
{
public class Token
{
public string AccessToken { get; set; }
public DateTime Expiration { get; set; }
public string RefreshToken { get; set; }
}
}
16 changes: 16 additions & 0 deletions Core/HyBe.Application/DTOs/User/CreateUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.DTOs.User
{
public class CreateUser
{
public string NameSurname { get; set; }
public string Username { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string PasswordConfirm { get; set; }
}
}
13 changes: 13 additions & 0 deletions Core/HyBe.Application/DTOs/User/CreateUserResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.DTOs.User
{
public class CreateUserResponse
{
public bool Succeeded { get; set; }
public string Message { get; set; }
}
}
Empty file.
22 changes: 22 additions & 0 deletions Core/HyBe.Application/Exceptions/AuthenticationErrorException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Exceptions
{
public class AuthenticationErrorException : Exception
{
public AuthenticationErrorException() :base("Kimlik doğrulama hatası!")
{
}

public AuthenticationErrorException(string? message) : base(message)
{
}

public AuthenticationErrorException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
}
22 changes: 22 additions & 0 deletions Core/HyBe.Application/Exceptions/NotFoundUserException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Exceptions
{
public class NotFoundUserException : Exception
{
public NotFoundUserException() : base("Kullanıcı adı veya şifre hatalı.")
{
}

public NotFoundUserException(string? message) : base(message)
{
}

public NotFoundUserException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
}
22 changes: 22 additions & 0 deletions Core/HyBe.Application/Exceptions/PasswordChangeFailedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Exceptions
{
public class PasswordChangeFailedException : Exception
{
public PasswordChangeFailedException() : base("Şifre güncellenirken bir sorun oluştu.")
{
}

public PasswordChangeFailedException(string? message) : base(message)
{
}

public PasswordChangeFailedException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
}
22 changes: 22 additions & 0 deletions Core/HyBe.Application/Exceptions/UserCreateFailedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Exceptions
{
public class UserCreateFailedException : Exception
{
public UserCreateFailedException() : base("Kullanıcı oluşturulurken beklenmeyen bir hatayla karşılaşıldı!")
{
}

public UserCreateFailedException(string? message) : base(message)
{
}

public UserCreateFailedException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HyBe.Application.Abstractions.Services;
using HyBe.Application.DTOs.User;
using MediatR;

namespace HyBe.Application.Features.AppUser.Commands.CreateUser
{
public class CreateUserCommandHandler:IRequestHandler<CreateUserCommandRequest, CreateUserCommandResponse>
{
readonly IUserService _userService;
public CreateUserCommandHandler(IUserService userService)
{
_userService = userService;
}

public async Task<CreateUserCommandResponse> Handle(CreateUserCommandRequest request, CancellationToken cancellationToken)
{
CreateUserResponse response = await _userService.CreateAsync(new()
{
Email = request.Email,
NameSurname = request.NameSurname,
Password = request.Password,
PasswordConfirm = request.PasswordConfirm,
Username = request.Username,
});

return new()
{
Message = response.Message,
Succeeded = response.Succeeded,
};

//throw new UserCreateFailedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Features.AppUser.Commands.CreateUser
{
public class CreateUserCommandRequest : IRequest<CreateUserCommandResponse>
{
public string NameSurname { get; set; }
public string Username { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string PasswordConfirm { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HyBe.Application.Features.AppUser.Commands.CreateUser
{
public class CreateUserCommandResponse
{
public bool Succeeded { get; set; }
public string Message { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using HyBe.Application.Abstractions.Services;
using MediatR;

namespace HyBe.Application.Features.AppUser.Commands.LoginUser
{
public class LoginUserCommandHandler : IRequestHandler<LoginUserCommandRequest, LoginUserCommandResponse>
{
readonly IAuthService _authService;
public LoginUserCommandHandler(IAuthService authService)
{
_authService = authService;
}

public async Task<LoginUserCommandResponse> Handle(LoginUserCommandRequest request, CancellationToken cancellationToken)
{
var token = await _authService.LoginAsync(request.UsernameOrEmail, request.Password);
return new LoginUserSuccessCommandResponse()
{
Token = token
};
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using MediatR;

namespace HyBe.Application.Features.AppUser.Commands.LoginUser
{
public class LoginUserCommandRequest : IRequest<LoginUserCommandResponse>
{
public string UsernameOrEmail { get; set; }
public string Password { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using HyBe.Application.DTOs;

namespace HyBe.Application.Features.AppUser.Commands.LoginUser
{
public class LoginUserCommandResponse
{

}
public class LoginUserSuccessCommandResponse : LoginUserCommandResponse
{
public Token Token { get; set; }
}
public class LoginUserErrorCommandResponse : LoginUserCommandResponse
{
public string Message { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using HyBe.Application.Abstractions.Services;
using HyBe.Application.DTOs;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HyBe.Application.Features.AppUser.Commands.RefreshTokenLogin
{
public class RefreshTokenLoginCommandHandler : IRequestHandler<RefreshTokenLoginCommandRequest, RefreshTokenLoginCommandResponse>
{
readonly IAuthService _authService;
public RefreshTokenLoginCommandHandler(IAuthService authService)
{
_authService = authService;
}

public async Task<RefreshTokenLoginCommandResponse> Handle(RefreshTokenLoginCommandRequest request, CancellationToken cancellationToken)
{
Token token = await _authService.RefreshTokenLoginAsync(request.RefreshToken);
return new()
{
Token = token
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HyBe.Application.Features.AppUser.Commands.RefreshTokenLogin
{
public class RefreshTokenLoginCommandRequest : IRequest<RefreshTokenLoginCommandResponse>
{
public string RefreshToken { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HyBe.Application.DTOs;

namespace HyBe.Application.Features.AppUser.Commands.RefreshTokenLogin
{
public class RefreshTokenLoginCommandResponse
{
public Token Token { get; set; }
}
}
Loading