admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
41
42
Quintiq file version 2.0
#parent: #root
Method CanProcessUser (
  output String feedback_o,
  const SWF_User user,
  String action
) const declarative remote as Boolean
{
  Description: 'Indicate if this user can process the [action] for the given [user].'
  TextBody:
  [*
    result := true;
    
    // Current user can only edit their own profile while admin can edit all user
    // Only admin can set user as active/inactive
    if( not this.IsAdministrator() 
        and ( action = SWF_User::ACTION_Edit() and user <> this )
            or ( action = SWF_User::ACTION_SetActive()
                  or action = SWF_User::ACTION_SetInActive() ) )
        
    {
      result := false;
      feedback_o := SWF_Translation::TRANSLATE_Auth_UnauthorizeAction();
    }
    // Only active user can be set to inactive
    else if( action = SWF_User::ACTION_SetInActive()
             and not user.IsActive() )
    {
      result := false;
      feedback_o := SWF_Translation::TRANSLATE_Auth_ProcessUser_IsInactive();
    }
    // Only inactive user can be set to active
    else if( action = SWF_User::ACTION_SetActive()
             and user.IsActive() )
    {
      result := false;
      feedback_o := SWF_Translation::TRANSLATE_Auth_ProcessUser_IsActive();
    }
    
    return result;
  *]
}