Automatically verify CLAs when the admin requests them

In Android's use of Gerrit 1 individual CLAs are automatically marked
as verified by the system if the contact information has been filled
out by the end-user.  This was done to avoid the rush of accounts as
the site opened for first use.

Corporations installing Gerrit 2 within their own firewall and with
their own SSO system might want to allow users to be covered by a
CLA automatically; permitting them to be auto-verified can simplify
that setup task.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-05 14:05:34 -08:00
parent 0dc1c1293e
commit 2cc42fa3f9
7 changed files with 45 additions and 21 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.reviewdb.AccountSshKey;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.rpc.SignInRequired;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
@@ -42,4 +43,8 @@ public interface AccountSecurity extends RemoteJsonService {
@SignInRequired
void updateContact(String fullName, String emailAddr,
ContactInformation info, AsyncCallback<VoidResult> callback);
@SignInRequired
void enterAgreement(ContributorAgreement.Id id,
AsyncCallback<VoidResult> callback);
}

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountProjectWatch;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.rpc.SignInRequired;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.AllowCrossSiteRequest;
@@ -49,8 +48,4 @@ public interface AccountService extends RemoteJsonService {
@SignInRequired
@AllowCrossSiteRequest
void myAgreements(AsyncCallback<AgreementInfo> callback);
@SignInRequired
void enterAgreement(ContributorAgreement.Id id,
AsyncCallback<VoidResult> callback);
}

View File

@@ -15,9 +15,7 @@
package com.google.gerrit.client.account;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountAgreement;
import com.google.gerrit.client.reviewdb.AccountProjectWatch;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.rpc.BaseServiceImplementation;
@@ -140,17 +138,4 @@ public class AccountServiceImpl extends BaseServiceImplementation implements
}
});
}
public void enterAgreement(final ContributorAgreement.Id id,
final AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>() {
public VoidResult run(final ReviewDb db) throws OrmException {
final AccountAgreement a =
new AccountAgreement(new AccountAgreement.Key(RpcUtil
.getAccountId(), id));
db.accountAgreements().insert(Collections.singleton(a));
return VoidResult.INSTANCE;
}
});
}
}

View File

@@ -216,7 +216,7 @@ public class NewAgreementScreen extends AccountScreen {
if (contactGroup.isVisible()) {
contactPanel.doSave();
}
Util.ACCOUNT_SVC.enterAgreement(current.getId(),
Util.ACCOUNT_SEC.enterAgreement(current.getId(),
new GerritCallback<VoidResult>() {
public void onSuccess(final VoidResult result) {
History.newItem(Link.SETTINGS_AGREEMENTS);

View File

@@ -60,6 +60,10 @@ public final class ContributorAgreement {
@Column
protected boolean requireContactInformation;
/** Does this agreement automatically verify new accounts? */
@Column
protected boolean autoVerify;
/** A short name for the agreement. */
@Column(length = 40)
protected String shortName;
@@ -107,6 +111,14 @@ public final class ContributorAgreement {
groupAgreement = g;
}
public boolean isAutoVerify() {
return autoVerify;
}
public void setAutoVerify(final boolean g) {
autoVerify = g;
}
public boolean isRequireContactInformation() {
return requireContactInformation;
}

View File

@@ -16,9 +16,11 @@ package com.google.gerrit.server;
import com.google.gerrit.client.account.AccountSecurity;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountAgreement;
import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.reviewdb.AccountSshKey;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.rpc.BaseServiceImplementation;
import com.google.gerrit.client.rpc.NoSuchEntityException;
@@ -129,4 +131,25 @@ public class AccountSecurityImpl extends BaseServiceImplementation implements
}
});
}
public void enterAgreement(final ContributorAgreement.Id id,
final AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>() {
public VoidResult run(final ReviewDb db) throws OrmException, Failure {
final ContributorAgreement cla = db.contributorAgreements().get(id);
if (cla == null || !cla.isActive()) {
throw new Failure(new NoSuchEntityException());
}
final AccountAgreement a =
new AccountAgreement(new AccountAgreement.Key(RpcUtil
.getAccountId(), id));
if (cla.isAutoVerify()) {
a.review(AccountAgreement.Status.VERIFIED, null);
}
db.accountAgreements().insert(Collections.singleton(a));
return VoidResult.INSTANCE;
}
});
}
}