You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Angela Schreiber (Jira)" <ji...@apache.org> on 2021/01/29 09:13:00 UTC

[jira] [Commented] (SLING-10103) UserUtil.disableUser throws IllegalArgumentException for null reason

    [ https://issues.apache.org/jira/browse/SLING-10103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17274261#comment-17274261 ] 

Angela Schreiber commented on SLING-10103:
------------------------------------------

additional comment: the method could be additionally simplified by looking up the user specifying the type in the user manager method. like this (including fixing inconsistent indention):

{code}
public static boolean disableUser(Session session, String id, String reason) throws RepositoryException {
        User user = getUserManager(session).getAuthorizable(id, User.class);
        if (user != null) {
            user.disable(reason);
            return true;
        } else {
            return false;
        }
    }
{code}

> UserUtil.disableUser throws IllegalArgumentException for null reason
> --------------------------------------------------------------------
>
>                 Key: SLING-10103
>                 URL: https://issues.apache.org/jira/browse/SLING-10103
>             Project: Sling
>          Issue Type: Bug
>          Components: Repoinit
>            Reporter: Angela Schreiber
>            Priority: Minor
>
> {code}
> public static boolean disableUser(Session session, String id, String reason) throws RepositoryException {
>         if (reason == null) {
>             throw new IllegalArgumentException("reason can't be null");
>         }
>         ....
>     }
> {code}
> i am not sure why this throws an exception, but i know for sure that a null reason is a valid argument in {{User.disable(String}}.
> {code}
> /**
>      * Disable this user thus preventing future login if the <code>reason</code>
>      * is a non-null String.<br>
>      * Note however, that this user will still be accessible by
>      * {@link UserManager#getAuthorizable}.
>      *
>      * @param reason String describing the reason for disable this user or
>      * <code>null</code> if the user account should be enabled again.
>      * @throws RepositoryException If an error occurs.
>      */
>     void disable(@Nullable String reason) throws RepositoryException;
> {code}
> i would suggest to remove that check.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)