wyona/yanel — Issue #4: Small bug in YanelServlet.setIdentity()
Author: baszero
Created: 2011-10-24 13:07:34+00:00
State: open

Today I discovered this little bug.

**Requirement:**

- At some point you would like to refresh the identity object in the current session (e.g. to reload all groups the user belongs to)

**Solution:**

- Yanel provides this method to refresh an identity in the current session:

```java
YanelServlet.setIdentity(new Identity(user, user.getEmail()), environment.getRequest().getSession(), realm);
```

**Bug:**

- If you refresh the identity as shown above and you read the identity from the environment within the same request (environment.getIdentity()), the changes have not been done yet to that object.

Example: So this code won't work:

```java
YanelServlet.setIdentity(...); // we refresh the identity with new groups
if (environment.getIdentity().getGroupnames()....) {
// if the condition of this IF depends on the just updated groups, it will not match and hence break your business logic.
}
```

**Proposal:**

- YanelServlet.setIdentity() should also update all identity copies in Yanel specific objects (like environment).

If I find some time, I'll send a pull request and make a reference to this issue here.