Changeset 7114


Ignore:
Timestamp:
Mar 16, 2016, 9:17:01 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1995: Add extension point for selecting start page

The login handling should now support this feature. It is available from the main login page and from the "Switch user" dialog when the "Remain on this page" is not checked. The login page that is shown after an automatic logout due to a timeout does not support this feature since it may interfere with what the user doing.

A concern is that the new start page doean't exists or has an error of some sort. In this case it may result in a lockout of the user. To prevent this a special page for handling "404 Not found" errors have been created. This page should display the regular BASE menu and allow the user to continue and modify the start page setting.

If this doesn't work it is also possible to hold down CTRL or ALT or SHIFT while clicking on the "Login" button. This will disable the extension start page and always display the regular home page instead.

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/web.xml

    r6632 r7114  
    3636    <exception-type>java.lang.Throwable</exception-type>
    3737    <location>/exception/exception.jsp</location>
     38  </error-page>
     39 
     40  <error-page>
     41    <error-code>404</error-code>
     42    <location>/exception/404.jsp</location>
    3843  </error-page>
    3944 
  • trunk/www/exception/not_logged_in.jsp

    r6635 r7114  
    100100      <input type="hidden" name="ID" value="<%=ID%>">
    101101      <input type="hidden" name="redirect" value="<%=redirect%>">
     102      <input type="hidden" name="useAutoStartPage" value="0">
    102103 
    103104      <table style="margin: auto; width: 700px; margin-top:5em; ">
  • trunk/www/login.js

    r7001 r7114  
    154154    if (frm.login && frm.login.disabled) return;
    155155
     156    // Disable start page extension if special key is used
     157    var specialKey = event.altKey || event.ctrlKey || event.shiftKey;
     158   
    156159    // Check if the login is not recommended
    157160    var denyLogin = Doc.element('denyLogin');
     
    186189      else
    187190      {
    188         frm.redirect.value = App.getRoot()+'my_base/index.jsp?ID='+getSessionId();
    189       }
    190     }
     191        frm.useAutoStartPage.value = '1';
     192        frm.redirect.value = App.getRoot()+'my_base/index.jsp?ID='+App.getSessionId();
     193      }
     194    }
     195   
     196    if (specialKey && frm.useAutoStartPage) frm.useAutoStartPage.value = '0';
    191197   
    192198    if (frm.target) Dialogs.openPopup('', frm.target, 300, 200);
  • trunk/www/login.jsp

    r6424 r7114  
    2828  @param login The login for the user.
    2929  @param password The password for the user.
    30   @param nextpage The URL for the next page to show. If not
    31     specified the current page is reloaded
    3230
    3331  @author Nicklas
     
    3735  import="net.sf.basedb.core.*"
    3836  import="net.sf.basedb.core.authentication.LoginRequest"
     37  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    3938  import="net.sf.basedb.clients.web.Base"
    4039  import="net.sf.basedb.clients.web.WebException"
     40  import="net.sf.basedb.clients.web.extensions.JspContext"
     41  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     42  import="net.sf.basedb.clients.web.extensions.startpage.StartPageAction"
    4143  import="net.sf.basedb.clients.web.util.HTML"
    4244  import="net.sf.basedb.util.Values"
     45  import="java.util.Iterator"
    4346%>
    4447<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    4851  String cmd = request.getParameter("cmd");
    4952  String again = request.getParameter("again");
     53  boolean useAutoStartPage = Values.getBoolean(request.getParameter("useAutoStartPage"));
    5054  String root = request.getContextPath()+"/";
    5155  String redirect = Values.getStringOrNull(request.getParameter("redirect"));
     
    5761  {
    5862    String password = request.getParameter("password");
     63    DbControl dc = null;
    5964    try
    6065    {
     
    6267      LoginRequest loginRequest = new LoginRequest(login, password);
    6368      sc.login(loginRequest);
     69     
     70      if (useAutoStartPage)
     71      {
     72        String startPageId = sc.getUserClientSetting("start-page-id");
     73        if (startPageId != null)
     74        {
     75          dc = sc.newDbControl();
     76          User user = User.getById(dc, sc.getLoggedInUserId());
     77          JspContext context = ExtensionsControl.createContext(dc, pageContext, null, user);
     78          ExtensionsInvoker<StartPageAction> invoker = (ExtensionsInvoker<StartPageAction>)ExtensionsControl.useExtensions(context, "net.sf.basedb.clients.web.start-page");
     79          Iterator<StartPageAction> it = invoker.iterator();
     80          while (it.hasNext())
     81          {
     82            try
     83            {
     84              StartPageAction action = it.next();
     85              if (startPageId.equals(action.getId()))
     86              {
     87                String startPage = action.getUrl();
     88                if (startPage != null)
     89                {
     90                  redirect = startPage.replace("$SESSION-ID$", sc.getId());
     91                }
     92                break;
     93              }
     94            }
     95            catch (RuntimeException ex)
     96            {}
     97          }
     98        }
     99      }
    64100    }
    65101    catch (LoginException ex)
     
    83119      errorMessage = ex.getMessage();
    84120    }
    85 
     121    finally
     122    {
     123      if (dc != null) dc.close();
     124    }
    86125  }
    87126  else if ("Impersonate".equals(cmd))
  • trunk/www/main.jsp

    r6632 r7114  
    111111    <form name="login" action="login.jsp" method="post">
    112112    <input type="hidden" name="ID" value="<%=ID%>">
    113     <input type="hidden" name="nextpage" value="<%=root%>my_base/user/index.jsp">
     113    <input type="hidden" name="useAutoStartPage" value="1">
    114114   
    115115    <table style="margin: auto; width: 700px;">
  • trunk/www/switch.jsp

    r6607 r7114  
    9292    <input type="hidden" name="again" value="1">
    9393    <input type="hidden" name="redirect" value="">
     94    <input type="hidden" name="useAutoStartPage" value="0">
    9495 
    9596    <div class="content">
Note: See TracChangeset for help on using the changeset viewer.