InvitesRestのメソッドの追加 トークン認証を行うメソッドを追加しました。 #44

Merged m-nagae merged 1 commit into nitta-lab-2021:master from nitta-lab-2021:AcccountInvitesRest on 18 May 2021
Showing 1 changed file
View
47
src/main/java/org/ntlab/acanthus_server/resources/accounts/InvitesRest.java
package org.ntlab.acanthus_server.resources.accounts;
 
import org.ntlab.acanthus_server.entities.Account;
import org.ntlab.acanthus_server.entities.Animation;
import org.ntlab.acanthus_server.models.Accounts;
import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.Collections;
 
@Component
@Path("/accounts/invites")
@Path("/accounts")
public class InvitesRest {
 
public class InvitesRest{
private Accounts accounts = Accounts.getInstance();
 
/**
*accountごとの招待されている作品の表示
*トークン認証
*
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public boolean hasLoginToken(@QueryParam("uid") int uid, @QueryParam("token") String token) {
 
var searchAccount = accounts.getAccountByUid(uid);
 
if (searchAccount == null) throw new WebApplicationException(404);
if (!searchAccount.getToken().equals(token)) throw new WebApplicationException(400);
 
return true;
}
}