summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/frontend/LogoutResource.java
blob: e26dcb752223a5d728da96a1a2749e412a807b4f (plain)
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
37
38
39
40
/*
 * Copyright 2013 Jesse Morgan
 */

package com.p4square.grow.frontend;

import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.ServerResource;

import com.p4square.session.Sessions;

import com.p4square.grow.config.Config;

/**
 * This Resource removes a user's session and session cookies.
 *
 * @author Jesse Morgan <jesse@jesterpm.net>
 */
public class LogoutResource extends ServerResource {
    private Config mConfig;

    @Override
    protected void doInit() {
        super.doInit();

        GrowFrontend growFrontend = (GrowFrontend) getApplication();
        mConfig = growFrontend.getConfig();
    }

    @Override
    protected Representation get() {
        Sessions.getInstance().delete(getRequest(), getResponse());

        String nextPage = mConfig.getString("dynamicRoot", "");
        nextPage += "/index.html";
        getResponse().redirectSeeOther(nextPage);
        return new StringRepresentation("Redirecting to " + nextPage);
    }
}