Changeset 7707


Ignore:
Timestamp:
May 13, 2019, 11:30:33 AM (2 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2176: Get name of active project and logged in user from SessionControl?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.15-stable/src/core/net/sf/basedb/core/SessionControl.java

    r7689 r7707  
    396396    li.userId = 0;
    397397    li.userLogin = null;
     398    li.userName = null;
    398399    li.authenticationMethod = AuthenticationMethod.INTERNAL;
    399400    loginInfo = li;
     
    11071108    li.userId = userData.getId();
    11081109    li.userLogin = userData.getLogin();
     1110    li.userName = userData.getName();
    11091111    li.authenticationMethod = authenticationMethod;
    11101112    li.sessionSettings = Collections.synchronizedMap(new HashMap<String,Object>());
     
    11891191    updateLastAccess();
    11901192    return loginInfo == null ? 0 : loginInfo.userId;
     1193  }
     1194 
     1195  /**
     1196    Get the login name of the currently logged in user.
     1197    Returns null if no user is logged in.
     1198    @see User#getLogin()
     1199    @since 3.15.1
     1200  */
     1201  public String getLoggedInUserLogin()
     1202  {
     1203    updateLastAccess();
     1204    return loginInfo == null ? null : loginInfo.userLogin;
     1205  }
     1206 
     1207  /**
     1208    Get the name of the currently logged in user.
     1209    Returns null if no user is logged in.
     1210    @see User#getName()
     1211    @since 3.15.1
     1212  */
     1213  public String getLoggedInUserName()
     1214  {
     1215    updateLastAccess();
     1216    return loginInfo == null ? null : loginInfo.userName;
    11911217  }
    11921218 
     
    13181344    return loginInfo == null ? 0 : loginInfo.activeProjectId;
    13191345  }
     1346 
     1347  /**
     1348    Get the name of the active project, or null if no project is active.
     1349    @see #setActiveProject(Project)
     1350    @since 3.15.1
     1351  */
     1352  public String getActiveProjectName()
     1353  {
     1354    updateLastAccess();
     1355    return loginInfo == null ? null : loginInfo.activeProjectName;
     1356  }
    13201357
    13211358  /**
     
    13421379        loginInfo.keyring.setActiveProject(null);
    13431380        loginInfo.activeProjectId = 0;
     1381        loginInfo.activeProjectName = null;
    13441382        loginInfo.projectKeyId = 0;
    13451383        loginInfo.itemKeyId = 0;
     
    13501388        loginInfo.keyring.setActiveProject(project.getData());
    13511389        loginInfo.activeProjectId = project.getId();
     1390        loginInfo.activeProjectName = project.getName();
    13521391        if (project.hasPermission(Permission.USE))
    13531392        {
     
    27142753    */
    27152754    private String userLogin;
     2755
     2756    /**
     2757      The name property of the logged in user.
     2758    */
     2759    private String userName;
    27162760   
    27172761    /**
     
    27342778
    27352779    /**
     2780      The name of the the active project.
     2781    */
     2782    private String activeProjectName;
     2783
     2784    /**
    27362785      The id of the {@link ProjectKeyData} object that new items should
    27372786      be shared to.
     
    27742823      this.userId = parent.userId;
    27752824      this.userLogin = parent.userLogin;
     2825      this.userName = parent.userName;
    27762826      this.deviceId = parent.deviceId;
    27772827      this.activeProjectId = parent.activeProjectId;
     2828      this.activeProjectName = parent.activeProjectName;
    27782829      this.projectKeyId = parent.projectKeyId;
    27792830      this.keyring = parent.keyring;
Note: See TracChangeset for help on using the changeset viewer.