0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-04 20:52:45 +01:00
construct/modules/client/user/openid.cc

59 lines
1.5 KiB
C++
Raw Normal View History

// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#include "user.h"
using namespace ircd;
static m::resource::response
post__openid__request_token(client &client,
const m::resource::request &request,
const m::user::id &user_id);
m::resource::response
post__openid(client &client,
const m::resource::request &request,
const m::user::id &user_id)
{
if(user_id != request.user_id)
throw m::FORBIDDEN
{
"Trying to post openid for `%s' but you are `%s'",
user_id,
request.user_id
};
// request.parv[0] = <user_id>
// request.parv[1] = "openid"
const string_view &cmd
{
request.parv[2]
};
if(cmd == "request_token")
return post__openid__request_token(client, request, user_id);
throw m::NOT_FOUND
{
"/user/openid command not found"
};
}
m::resource::response
post__openid__request_token(client &client,
const m::resource::request &request,
const m::user::id &user_id)
{
return m::resource::response
{
client, http::TOO_MANY_REQUESTS
};
}