mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: login & registration; enhanced paste view; custom dropdown + search; navbar; global user access via store; auto token refresh; paste creation as user; /api/user/me, returns info on yourself including pastes;
fix: auth check refactor: remove user UID api endpoint
This commit is contained in:
@@ -8,10 +8,36 @@ namespace SharpbinV3.Server.Services
|
||||
public sealed class UserService(AppDbContext db) : IUserService
|
||||
{
|
||||
private readonly AppDbContext _db = db;
|
||||
public Task<User?> GetByUID(int uid, bool withPastes = false)
|
||||
{
|
||||
IQueryable<User> query = _db.Users;
|
||||
if (withPastes)
|
||||
query = query.Include(u => u.Pastes);
|
||||
return query.FirstOrDefaultAsync(u => u.UID == uid);
|
||||
}
|
||||
|
||||
public Task<User?> GetByUID(int uid) => _db.Users.FirstOrDefaultAsync(u => u.UID == uid);
|
||||
public Task<User?> GetByUUID(Guid uuid) => _db.Users.FirstOrDefaultAsync(u => u.UUID == uuid);
|
||||
public Task<User?> GetByUsername(string username) => _db.Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||
public Task<User?> GetByEmail(string email) => _db.Users.FirstOrDefaultAsync(u => u.Email == email);
|
||||
public Task<User?> GetByUUID(Guid uuid, bool withPastes = false)
|
||||
{
|
||||
IQueryable<User> query = _db.Users;
|
||||
if (withPastes)
|
||||
query = query.Include(u => u.Pastes);
|
||||
return query.FirstOrDefaultAsync(u => u.UUID == uuid);
|
||||
}
|
||||
|
||||
public Task<User?> GetByUsername(string username, bool withPastes = false)
|
||||
{
|
||||
IQueryable<User> query = _db.Users;
|
||||
if (withPastes)
|
||||
query = query.Include(u => u.Pastes);
|
||||
return query.FirstOrDefaultAsync(u => u.Username == username);
|
||||
}
|
||||
|
||||
public Task<User?> GetByEmail(string email, bool withPastes = false)
|
||||
{
|
||||
IQueryable<User> query = _db.Users;
|
||||
if (withPastes)
|
||||
query = query.Include(u => u.Pastes);
|
||||
return query.FirstOrDefaultAsync(u => u.Email == email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user