2023-12-30 22:42:11 +00:00
|
|
|
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
//SPDX-License-Identifier: GPL-3.0-or-later
|
2023-12-22 23:25:20 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-30 22:42:11 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2023-12-22 23:25:20 +00:00
|
|
|
#include "handler.h"
|
|
|
|
|
|
|
|
class Server;
|
|
|
|
namespace Handler {
|
|
|
|
|
|
|
|
class Login : public Handler {
|
|
|
|
public:
|
2024-01-22 18:21:55 +00:00
|
|
|
Login(const std::shared_ptr<Server>& server);
|
2023-12-22 23:25:20 +00:00
|
|
|
void handle(Request& request) override;
|
|
|
|
|
|
|
|
enum class Result {
|
|
|
|
success,
|
|
|
|
noLogin,
|
|
|
|
emptyLogin,
|
|
|
|
noPassword,
|
|
|
|
emptyPassword,
|
2023-12-28 20:26:08 +00:00
|
|
|
wrongCredentials,
|
2023-12-22 23:25:20 +00:00
|
|
|
unknownError
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
void error(Request& request, Result result, Response::Status code);
|
|
|
|
|
|
|
|
private:
|
2023-12-30 22:42:11 +00:00
|
|
|
std::weak_ptr<Server> server;
|
2023-12-22 23:25:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|