forked from deepseek-ai/3FS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecodeUserToken.cc
More file actions
36 lines (29 loc) · 1.09 KB
/
Copy pathDecodeUserToken.cc
File metadata and controls
36 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "DecodeUserToken.h"
#include "client/cli/common/Dispatcher.h"
#include "client/cli/common/Utils.h"
#include "core/user/UserToken.h"
namespace hf3fs::client::cli {
namespace {
auto getParser() {
argparse::ArgumentParser parser("decode-user-token");
parser.add_argument("token");
return parser;
}
CoTryTask<Dispatcher::OutputTable> handleDecodeUserToken(IEnv &,
const argparse::ArgumentParser &parser,
const Dispatcher::Args &args) {
Dispatcher::OutputTable table;
ENSURE_USAGE(args.empty());
auto token = parser.get<std::string>("token");
auto res = core::decodeUserToken(token);
CO_RETURN_ON_ERROR(res);
auto [uid, ts] = *res;
table.push_back({"Uid", fmt::format("{}", uid)});
table.push_back({"Timestamp", fmt::format("{}", ts)});
co_return table;
}
} // namespace
CoTryTask<void> registerDecodeUserTokenHandler(Dispatcher &dispatcher) {
co_return co_await dispatcher.registerHandler(getParser, handleDecodeUserToken);
}
} // namespace hf3fs::client::cli