Skip to content
Snippets Groups Projects
Commit f17ae9de authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Cleanup

parent 6fa86363
No related branches found
No related tags found
1 merge request!1New: Api that handles Token Creation
Pipeline #367637 passed
......@@ -43,8 +43,8 @@ namespace Coscine.Api.Token.Controllers
/// List all tokens of the current user.
/// </summary>
/// <returns>200 (Json) of list of tokens, 401 if unauthorized.</returns>
[HttpGet("[controller]/")]
public ActionResult<List<ApiTokenObject>> GetUserTokens()
[HttpGet("[controller]")]
public ActionResult<IEnumerable<ApiTokenObject>> GetUserTokens()
{
var user = _authenticator.GetUserId();
var tokens = _apiTokenModel.GetTokens(user);
......@@ -53,7 +53,7 @@ namespace Coscine.Api.Token.Controllers
return Json(new List<ApiTokenObject>());
}
return Json(tokens.ToList());
return Json(tokens);
}
/// <summary>
......@@ -62,9 +62,9 @@ namespace Coscine.Api.Token.Controllers
/// <param name="tokenId">User tokenId</param>
/// <returns>StatusCode 200 (json) if ok, 404 if not found, 401 if unauthorized.</returns>
[HttpGet("[controller]/{tokenId}")]
public ActionResult<ApiTokenObject> GetUserToken(string tokenId)
public ActionResult<ApiTokenObject> GetUserToken(Guid tokenId)
{
var t = _apiTokenModel.GetToken(_authenticator.GetUser().Id, new Guid(tokenId));
var t = _apiTokenModel.GetToken(_authenticator.GetUser().Id, tokenId);
if (t == null)
{
return NotFound("Token not found");
......@@ -79,9 +79,9 @@ namespace Coscine.Api.Token.Controllers
/// <param name="tokenId">User tokenId</param>
/// <returns>StatusCode 204 successful revokation, 404 if token is not found, 401 if unauthorized.</returns>
[HttpDelete("[controller]/{tokenId}")]
public IActionResult RevokeToken(string tokenId)
public IActionResult RevokeToken(Guid tokenId)
{
var r = _apiTokenModel.Revoke(_authenticator.GetUser().Id, new Guid(tokenId));
var r = _apiTokenModel.Revoke(_authenticator.GetUser().Id, tokenId);
if (r == 0)
{
return NotFound();
......@@ -121,7 +121,7 @@ namespace Coscine.Api.Token.Controllers
var userId = _authenticator.GetUser().Id;
_apiTokenModel.InsertToken(tokenId, iat, exp, userId, addApiTokenParameter.Name);
var token = new CreatedApiTokenObject { Name = addApiTokenParameter.Name, Created = iat, Expires = exp, TokenId = tokenId.ToString(), Token = jwtToken };
var token = new CreatedApiTokenObject { Name = addApiTokenParameter.Name, Created = iat, Expires = exp, TokenId = tokenId, Token = jwtToken };
return Json(token);
}
}
......
......@@ -49,16 +49,16 @@
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.10.1.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.10.1-topic-1123-token0015\lib\net461\Coscine.ApiCommons.dll</HintPath>
<HintPath>..\packages\Coscine.ApiCommons.1.10.1-topic-1123-token0016\lib\net461\Coscine.ApiCommons.dll</HintPath>
</Reference>
<Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.Database, Version=1.26.1.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.26.1-topic-1125-apito0011\lib\net461\Coscine.Database.dll</HintPath>
<HintPath>..\packages\Coscine.Database.1.26.1-topic-1125-apito0012\lib\net461\Coscine.Database.dll</HintPath>
</Reference>
<Reference Include="Coscine.Database.T4, Version=1.26.1.0, Culture=neutral, PublicKeyToken=84b4c404a0696261, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.26.1-topic-1125-apito0011\lib\net461\Coscine.Database.T4.dll</HintPath>
<HintPath>..\packages\Coscine.Database.1.26.1-topic-1125-apito0012\lib\net461\Coscine.Database.T4.dll</HintPath>
</Reference>
<Reference Include="Coscine.JwtHandler, Version=1.2.0.0, Culture=neutral, PublicKeyToken=aaacf41df3a6253c, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.JwtHandler.1.2.0-topic-1125-apito0006\lib\net461\Coscine.JwtHandler.dll</HintPath>
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.ApiCommons" version="1.10.1-topic-1123-token0015" targetFramework="net461" />
<package id="Coscine.ApiCommons" version="1.10.1-topic-1123-token0016" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.Database" version="1.26.1-topic-1125-apito0011" targetFramework="net461" />
<package id="Coscine.Database" version="1.26.1-topic-1125-apito0012" targetFramework="net461" />
<package id="Coscine.JwtHandler" version="1.2.0-topic-1125-apito0006" targetFramework="net461" />
<package id="Coscine.Logging" version="1.2.0" targetFramework="net461" />
<package id="EntityFramework" version="6.4.4" targetFramework="net461" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment