jenkins-bot has submitted this change and it was merged.

Change subject: Check user group memberships on protected pages
......................................................................


Check user group memberships on protected pages

Now that we know what groups a user is a member of we can check
if the user is a member of any of the allowed groups to edit the page.

This will enable a logged in user to see the regular edit pencils instead
of the disabled ones. The server still ultimately checks permissions upon
an edit submission.

Bug: T132834
Change-Id: I01a180f256f3a82ac197ed23445e976581ca8813
---
M app/src/main/java/org/wikipedia/server/Protection.java
M app/src/main/java/org/wikipedia/server/restbase/RbPageLead.java
2 files changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Mholloway: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  Niedzielski: Looks good to me, approved



diff --git a/app/src/main/java/org/wikipedia/server/Protection.java 
b/app/src/main/java/org/wikipedia/server/Protection.java
index 73aff64..90fdedf 100644
--- a/app/src/main/java/org/wikipedia/server/Protection.java
+++ b/app/src/main/java/org/wikipedia/server/Protection.java
@@ -1,5 +1,6 @@
 package org.wikipedia.server;
 
+import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 
 /** Protection settings for a page */
@@ -14,4 +15,9 @@
         }
         return null;
     }
+
+    @NonNull
+    public String[] getEditRoles() {
+        return edit.clone();
+    }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/wikipedia/server/restbase/RbPageLead.java 
b/app/src/main/java/org/wikipedia/server/restbase/RbPageLead.java
index 4277ee2..21011c7 100644
--- a/app/src/main/java/org/wikipedia/server/restbase/RbPageLead.java
+++ b/app/src/main/java/org/wikipedia/server/restbase/RbPageLead.java
@@ -8,6 +8,7 @@
 import com.google.gson.annotations.SerializedName;
 
 import org.wikipedia.Site;
+import org.wikipedia.login.User;
 import org.wikipedia.page.GeoTypeAdapter;
 import org.wikipedia.page.Namespace;
 import org.wikipedia.page.Page;
@@ -185,7 +186,14 @@
 
     @Override
     public boolean isEditable() {
-        return editable;
+        return editable || isLoggedInUserAllowedToEdit();
+    }
+
+    private boolean isLoggedInUserAllowedToEdit() {
+        User user = User.getUser();
+        return user != null
+                && protection != null
+                && user.isAllowed(protection.getEditRoles());
     }
 
     @Override

-- 
To view, visit https://gerrit.wikimedia.org/r/313032
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I01a180f256f3a82ac197ed23445e976581ca8813
Gerrit-PatchSet: 19
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to