Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Various minor fixes and updates.
Browse files Browse the repository at this point in the history
Minor changes to the profile page.
Fix bug when restricting a project by roles.
Fix bug when initially signing up for an open id account and the account hasn't been created yet.
  • Loading branch information
Carlos Munoz committed Sep 14, 2012
1 parent 9ecf60e commit a80d774
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
Expand Up @@ -59,16 +59,22 @@ public class ProjectRoleRestrictionAction implements Serializable

private Map<String, Boolean> roleRestrictions;

private Boolean restrictByRoles;


@Out(required = false)
public boolean getRestrictByRoles()
{
return projectHome.getInstance().isRestrictedByRoles();
if( restrictByRoles == null )
{
restrictByRoles = projectHome.getInstance().isRestrictedByRoles();
}
return restrictByRoles;
}

public void setRestrictByRoles(boolean restrictByRoles)
{
projectHome.getInstance().setRestrictedByRoles(restrictByRoles);
this.restrictByRoles = restrictByRoles;
}

public Map<String, Boolean> getRoleRestrictions()
Expand Down
Expand Up @@ -23,12 +23,10 @@
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.zanata.dao.AccountRoleDAO;
import org.zanata.dao.PersonDAO;
import org.zanata.model.HAccount;
import org.zanata.model.HAccountRole;
import org.zanata.model.HLocale;
import org.zanata.model.HPerson;
import org.zanata.model.HProject;

/**
Expand All @@ -50,9 +48,7 @@ public static boolean isUserAllowedAccess( HProject project )

if( identity != null )
{
AccountRoleDAO accountRoleDAO = (AccountRoleDAO)Component.getInstance(AccountRoleDAO.class);

for(HAccountRole role : accountRoleDAO.getByProject(project))
for(HAccountRole role : project.getAllowedRoles())
{
if( identity.hasRole( role.getName() ) )
{
Expand Down
13 changes: 9 additions & 4 deletions zanata-war/src/main/java/org/zanata/security/ZanataOpenId.java
Expand Up @@ -319,12 +319,17 @@ public void afterOpenIdAuth(OpenIdAuthenticationResult result)
if( result.isAuthenticated() )
{
HAccount authenticatedAccount = accountDAO.getByCredentialsId( result.getAuthenticatedId() );
credentials.setUsername( authenticatedAccount.getUsername() );
Identity.instance().acceptExternallyAuthenticatedPrincipal((new OpenIdPrincipal(result.getAuthenticatedId())));

if( Events.exists() )
// If the user hasn't been registered, there is no authenticated account
if( authenticatedAccount != null )
{
Events.instance().raiseEvent(AuthenticationManager.EVENT_LOGIN_COMPLETED, AuthenticationType.OPENID);
credentials.setUsername( authenticatedAccount.getUsername() );
Identity.instance().acceptExternallyAuthenticatedPrincipal((new OpenIdPrincipal(result.getAuthenticatedId())));

if( Events.exists() )
{
Events.instance().raiseEvent(AuthenticationManager.EVENT_LOGIN_COMPLETED, AuthenticationType.OPENID);
}
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions zanata-war/src/main/webapp/profile/view.xhtml
Expand Up @@ -34,19 +34,20 @@
</ui:define>

<ui:define name="center_content">
<h1>#{personHome.instance.name} - #{personHome.instance.account.username}</h1>
<h1>#{personHome.instance.name}</h1>
<h3>#{personHome.instance.account.username}</h3>
<br/>

<h:form>
<s:token allowMultiplePosts="true" />

<rich:panel style="background-color: white">
<rich:panel>
<table>
<tr>
<td><h2>#{messages['jsf.ApiKey']}</h2></td>
<td style="padding-left:15px"><h:commandButton action="#{personHome.regenerateApiKey}"
value="Generate API Key" reRender="api_key,no_api_key"
onclick="if (!confirm('Are you sure you want to generate your API Key?')) return false" class="hightlight_button"/></td>
onclick="if (!confirm('Are you sure you want to generate your API Key?')) return false" /></td>
</tr>
</table>
<s:span id="no_api_key" rendered="#{personHome.instance.account.apiKey == null}">#{messages['jsf.NotGenerated']}</s:span>
Expand All @@ -57,7 +58,7 @@
</s:fragment>
</rich:panel>

<rich:panel style="background-color: white">
<rich:panel>
<h2>#{messages['jsf.ConfigurationForZanataini']}</h2>
<textarea rows="5" readonly="true" class="code configTextArea">
[servers]
Expand Down
16 changes: 15 additions & 1 deletion zanata-war/src/main/webapp/stylesheet/2.0.css
Expand Up @@ -449,4 +449,18 @@ th,td {
.rich-datascr-inact:hover {
/*box-shadow: 0 0 5px grey inset;*/
}
/* End Richfaces Data scroller styles */
/* End Richfaces Data scroller styles */

/* Richfaces Tab panel styles */

.rich-tab-active {
background-color: #461446;
border-color: #461446;
color: #ffffff;
}

.rich-tab-inactive {
background-color: #eeeeee;
}

/* End Richfaces Tab panel styles */

0 comments on commit a80d774

Please sign in to comment.