https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/05.6.md
https://github.com/couchbaselabs/mini-hacks
Important !!
channels-users-roles
https://github.com/couchbaselabs/mini-hacks/tree/master/channels-users-roles
=====
level-1:未註冊使用者(發文要核準)
level-2:註冊使用者(發文不用核準)
level-3:版主(可核準或取消)
程式動態新增role
藍線:建立role
綠線:回覆結果
.角色(Roles)和使用者(users) 是可以被授權 而訪問 Channels.
使用者(users) 被附予角色(Roles),則可以 用角色的授權 進而訪問 Channels
.channel(channelname) 有讀取權限
access(doc.owner, channelname); 給 寫入權限
requireUser(doc.owner) requireRole(doc.role) 也可以給 寫入權限
document content (using throw) ???
讀和寫權限是分開的。
寫的權限完全是用sync function控制:除非sync function拒絕………
Write
requireUser(username) 是否是該使用者(User)
requireRole(rolename) 是否有該角色(Role)
requireAccess(channels) 是否有該Channel
curl -vX POST -H ‘Content-Type: application/json’ \ –cookie ‘SyncGatewaySession=d007ceb561f0111512c128040c32c02ea9d90234’ \ :4984/db/ \ -d ‘{“type”: “review”, “role”: “level-1”, “owner”: “jens”}’
{“type”: “review”, “role”: “level-1”, “owner”: “jens”} =>
Can not understand couchbase todolite demo Q1: doucment id p:xxoooxx Q2:facebook login auto add user
http://stackoverflow.com/questions/30905279/can-not-understand-couchbase-todolite-demo/30931841#30931841
http://stackoverflow.com/questions/20822285/couchbase-lite-stops-syncing-when-an-app-resumes-from-background
answered Dec 30 ‘13 at 12:55
MonkeyBonkey
Looks like if I set the replication to “persistent” it resumes on app backgrounding
e.g._pull.persistent = YES;
https://github.com/couchbaselabs/ToDoLite-Android
Write ToDoLite database sync guy is very good.
OK, take out.
android studio:new project then
Copy todolist four java : Application.java、BaseActivity.java、Preferences.java、Synchronize.java
Edit java : MainActivityjava、AndroidManifes.xml 1、app/src/main/AndroidManifest.xml
<application add android:name=“com.sandk.groupaccountbook.Application”
2、app/src/main/java/com/sandk/groupaccountbook/MainActivity.java
change public class MainActivity extends ActionBarActivity => public class MainActivity extends BaseActivity {
If have new activity, just change extends to BaseActivity, then can use application.getDatabase().
1. activity_main.xml => tools:context=".MainActivity" => MainActivity.java
…….I try first… is more better then post.
=========
=========
===== suggestion newbie =====
https://github.com/couchbaselabs/CouchbaseLite-DevDay-StarterKit
https://github.com/couchbaselabs/GrocerySync-Android
https://github.com/couchbaselabs/ToDoLite-Android (Hard Understand) SO see this first:
http://sueboy.blogspot.com/2015/06/couchbase-todolist-get-database-sync.html
=========
MainActivity.java
BuildConfig – 來自 build.gradle ( Module.app ) 目錄app – build.gradle
extends ActionBarActivity – http://blog.tonycube.com/2014/02/android-actionbarcompat-1.html
Intent – http://www.imyukin.com/?p=183
– http://kezeodsnx.pixnet.net/blog/post/27072894-android-----%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E8%87%AA%E6%88%91%E4%BB%8B%E7%B4%B9%E4%B9%8Bintent-resolution
startService – http://blog.maxkit.com.tw/2014/01/android-serviceintentservice.html
– http://blog.kenyang.net/2012/11/android-startservice-vs-bindservice.html
– http://blog.csdn.net/biezhihua/article/details/44439897
context.bindService() <==> context.startService()
context.startService() ==> Service <==> IntentService
突然想到,他的basic auth,其實不是用來給系統用的,是給app用的
也就是app每一支都是用同樣的basicAuth id/pwd登入,區分 管理者和一般使用者
而一般使用者註冊後,帳密是另外開一個doucment,之後所有的文件管理是自己要控制的
跟mysql的一樣,不會給每個人有basic auth,權限管理,也是在sql下的時候,抓出資料做判斷
所以才會在 add user時,用restful curd,使用者代表不同的專案
==========
This is my think:
couchbase basic auth is not for every body login. It is app connect to sync_gateway for auth. Example is have normal user and Admin user. Maybe login sync_gateway, that get different document、channel、sync.
Normal user registered. The register data put in document, Maybe document name is “members” then system programmer need to control document show or not by permit.