From 01c56cbb9271f46f0620c33924443245b393c1fe Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Sat, 18 Aug 2012 15:04:11 +0200 Subject: [PATCH] oauth config wizard bzr revid: al@openerp.com-20120818130411-auxfh3lc0r801kym --- addons/auth_oauth/auth_oauth.py | 1 - addons/auth_oauth/res_config.py | 53 +++++++++++-------------------- addons/auth_oauth/res_config.xml | 42 ++++++++++++------------ addons/auth_signup/res_config.py | 3 +- addons/auth_signup/res_config.xml | 4 +++ addons/base_setup/res_config.py | 4 +-- addons/portal/__openerp__.py | 2 +- 7 files changed, 48 insertions(+), 61 deletions(-) diff --git a/addons/auth_oauth/auth_oauth.py b/addons/auth_oauth/auth_oauth.py index 8a7ba4e6e4d..34b6aa44936 100644 --- a/addons/auth_oauth/auth_oauth.py +++ b/addons/auth_oauth/auth_oauth.py @@ -17,7 +17,6 @@ class auth_oauth_provider(osv.osv): 'enabled' : fields.boolean('Allowed'), 'css_class' : fields.char('CSS class'), 'body' : fields.char('Body'), - 'active' : fields.boolean('Active'), 'sequence' : fields.integer(), } _defaults = { diff --git a/addons/auth_oauth/res_config.py b/addons/auth_oauth/res_config.py index 52d82b71895..82d79c767f5 100644 --- a/addons/auth_oauth/res_config.py +++ b/addons/auth_oauth/res_config.py @@ -28,51 +28,36 @@ class base_config_settings(osv.TransientModel): _inherit = 'base.config.settings' _columns = { - 'auth_oauth_google_enabled' : fields.boolean('Allow users to login with Google'), + 'auth_oauth_google_enabled' : fields.boolean('Allow users to sign in with Google'), 'auth_oauth_google_client_id' : fields.char('Client ID'), - 'auth_oauth_facebook_enabled' : fields.boolean('Allow users to login with Facebook'), + 'auth_oauth_facebook_enabled' : fields.boolean('Allow users to sign in with Facebook'), 'auth_oauth_facebook_client_id' : fields.char('Client ID'), } - def get_default_allow(self, cr, uid, fields, context=None): + def get_oauth_providers(self, cr, uid, fields, context=None): google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] - rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled'], context=context) facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] - rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled'], context=context) + rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled','client_id'], context=context) + rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled','client_id'], context=context) return { 'auth_oauth_google_enabled': rg[0]['enabled'], - 'auth_oauth_facebook_enabled': rf[0]['enabled'] + 'auth_oauth_google_client_id': rg[0]['client_id'], + 'auth_oauth_facebook_enabled': rf[0]['enabled'], + 'auth_oauth_facebook_client_id': rf[0]['client_id'], } - def set_allow(self, cr, uid, ids, context=None): + def set_oauth_providers(self, cr, uid, ids, context=None): google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] config = self.browse(cr, uid, ids[0], context=context) - self.pool.get('auth.oauth.provider').write(cr, uid, [google_id], {'enabled':config.auth_oauth_google_enabled}) - self.pool.get('auth.oauth.provider').write(cr, uid, [facebook_id], {'enabled':config.auth_oauth_facebook_enabled}) + rg = { + 'enabled':config.auth_oauth_google_enabled, + 'client_id':config.auth_oauth_google_client_id, + } + rf = { + 'enabled':config.auth_oauth_facebook_enabled, + 'client_id':config.auth_oauth_facebook_client_id, + } + self.pool.get('auth.oauth.provider').write(cr, uid, [google_id], rg) + self.pool.get('auth.oauth.provider').write(cr, uid, [facebook_id], rf) - # def get_default_client_ids(self, cr, uid, fields, context=None): - # google_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_google')[1] - # facebook_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_facebook')[1] - # return { - # 'auth_oauth_google_client_id': icp.get_param(cr, uid, 'auth.auth_oauth_google_client_id', "Set by the user") or False - # } - - # def set_client_ids(self, cr, uid, ids, context=None): - # provider_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'auth_oauth', 'provider_goole') - - - # config = self.browse(cr, uid, ids[0], context=context) - # icp = self.pool.get('ir.config_parameter') - # icp.set_param(cr, uid, 'auth.google_client_id', config.google_client_id) - - # def get_default_facebook_client_id(self, cr, uid, fields, context=None): - # icp = self.pool.get('ir.config_parameter') - # return { - # 'facebook_client_id': icp.get_param(cr, uid, 'auth.facebook_client_id', "Set by the user") or False - # } - - # def set_facebook_client_id(self, cr, uid, ids, context=None): - # config = self.browse(cr, uid, ids[0], context=context) - # icp = self.pool.get('ir.config_parameter') - # icp.set_param(cr, uid, 'auth.facebook_client_id', config.facebook_client_id) \ No newline at end of file diff --git a/addons/auth_oauth/res_config.xml b/addons/auth_oauth/res_config.xml index 78c5e26d983..2b06e05327a 100644 --- a/addons/auth_oauth/res_config.xml +++ b/addons/auth_oauth/res_config.xml @@ -1,7 +1,6 @@ - + - base.config.settings.oauth base.config.settings @@ -12,35 +11,34 @@
-
-
-

To setup the signin process with Google, first you have to perform the following steps:

+
+ To setup the signin process with Google, first you have to perform the following steps:

- 1. Register your application through the Google's APIs console. The result of this registration is a set of values that are known to both Google and you application: 'client_id' and 'redirect_uri'. + - Go to the Google APIs console
+ - Ceate a new project
+ - Go to Api Access
+ - Create an oauth client_id
+ - Edit settings and set both Authorized Redirect URIs and Authorized JavaScript Origins to your hostname.

- 2. Fill the following field with the values assigned by Google. -
-
-
+ Now copy paste the client_id here: +
-
-
-
-
-
-
+
+
+ To setup the signin process with Google, first you have to perform the following steps:
+
+ Now copy paste the client_id here: +
+
@@ -49,4 +47,4 @@
-
\ No newline at end of file + diff --git a/addons/auth_signup/res_config.py b/addons/auth_signup/res_config.py index a9a490de8c5..50dc332ac56 100644 --- a/addons/auth_signup/res_config.py +++ b/addons/auth_signup/res_config.py @@ -25,7 +25,8 @@ class base_config_settings(osv.TransientModel): _inherit = 'base.config.settings' _columns = { - 'auth_signup_template_user_id': fields.many2one('res.users', 'Template user for new users created through signup') + 'auth_signup_uninvited': fields.boolean('Allow uninvited users to sign up'), + 'auth_signup_template_user_id': fields.many2one('res.users', 'Template user for new users created through signup'), } def get_default_signup(self, cr, uid, fields, context=None): diff --git a/addons/auth_signup/res_config.xml b/addons/auth_signup/res_config.xml index f85d173792a..49669d36618 100644 --- a/addons/auth_signup/res_config.xml +++ b/addons/auth_signup/res_config.xml @@ -8,6 +8,10 @@ +
+ +