// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.server;

import com.google.appengine.api.users.UserServiceFactory;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Logout handler
 *
 * @author sharon@google.com (Sharon Perl)
 */
public class LogoutServlet extends OdeServlet {

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
    req.getSession().invalidate();
    res.sendRedirect("/");
  }
}

@@ -107,17 +107,17 @@
 2011-201
-2
+6
  MIT, Al
@@ -328,16 +328,65 @@
 Factory;
+%0Aimport com.google.appinventor.server.flags.Flag;
 %0A%0Aimport
@@ -623,16 +623,107 @@
 vlet %7B%0A%0A
+  private static final Flag%3CBoolean%3E useGoogle = Flag.createFlag(%22auth.usegoogle%22, true);%0A%0A
   @Overr
@@ -851,16 +851,211 @@
 date();%0A
+    if (useGoogle.get() == true) %7B%0A      res.sendRedirect(UserServiceFactory.getUserService().createLogoutURL(%22/%22));%0A      res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);%0A    %7D else %7B%0A  
     res.
@@ -1073,14 +1073,20 @@
 t(%22/%22);%0A
+    %7D%0A
   %7D%0A%7D%0A

Correctly Generate Google Logout