概念 : 过程 : 前台login

为了解决自动登入、访问权限机制、登入权限而诞生了这过程,过程需要概念来维护记忆。

通过singlePageAutoLoginLocalStorage, UIStateLocalStorage, User, 这3个对象是过程中会用到的

singlePageAutoLoginLocalStorage : {
    accountId : 5,
    singlePage : "employer"
}

UIStateRoleSelectedLocalStorage : {
    accountId : 5,
    singlePage : "employer",
    accountRole : "customer",
    stateUrl : "a/b/c"
}

user : {
    account : {},
    role : "",
    account : []
}

一个部分是负责auto login,另一个部分是负责page permission

 

过程:auto login

Hdlogin 把对象放去 rootscope.user

remove singlePageAutoLoginStorage data if user.accounts no match

match current single page & singlePageAutoLoginStorage for auto login

  if match, fill user.account (no fill account.user.role)

  if no, got callback(project'logic)

    if yes, return

      true, fill user.account, set singlePageAutoLoginStorage (no fill account.user.role)

      false, normal process

    if no, normal process

 

 

过程:page permission

setup the permission for every UIState, which is callback

  1. getUsaAccountTypeNames

  2. getSaRolesName

  3. redirectLoginUrl

  4. redirectSwitchUrl

     5. redirectToNoRolePermission

 

if user.account == undefined 

  if yes, redirectLoginUrl

  if no, check getUsaAccountTypeNames contain user.account.type

    if no, redirectLoginUrl

    if yes, process

    

filter pagePermissionRoles with user.account.roles (filter way is check every permissionRole got accountRole then keep, other remove)

  if pagePermissionRoles length == 0

    alert("your account roles is not allowed visit") > redirectToNoRolePermission

  if pagePermissionRoles.length > 0

    pagePermissionRoles contain UIStateRoleSelectedLocalStorage

      if yes, fill user.role

      if no, pagePermissionRoles.length == 1 ?

        if yes, fill user.role

        if no, pagePermissionRoles contain user.role ?

          if yes, fill user.role

          if no, redirectSwitchUrl

 

过程:login page

state.get(param) for the return url permission(mean success will redirect to returnUrl), the param come to url.

login page will show a select option for user select a accountType, this will let user know what the page need and ajax header need a selectedAccountType

succesfull will update the user.account and user.role

 

过程:logout

if auto login got project'logic, then logout also got project'logic, which is logout need clear all singlePageAutoLoginStorage or clear current singlePageAutoLoginStorage

 

posted @ 2015-10-17 21:50  泉油  阅读(299)  评论(0编辑  收藏  举报
Web Design Johor Bahru Malaysia - Stooges