[IMP]Put % Instead px in css.
[odoo/odoo.git] / addons / auth_oauth_signup / res_users.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2010-2012 OpenERP SA (<http://openerp.com>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import logging
23 import simplejson
24
25 import openerp
26 from openerp.osv import osv, fields
27
28 _logger = logging.getLogger(__name__)
29
30 class res_users(osv.Model):
31     _inherit = 'res.users'
32
33     def _auth_oauth_signin(self, cr, uid, provider, validation, params, context=None):
34         # overridden to use signup method if regular oauth signin fails
35         try:
36             login = super(res_users, self)._auth_oauth_signin(cr, uid, provider, validation, params, context=context)
37
38         except openerp.exceptions.AccessDenied:
39             if context and context.get('no_user_creation'):
40                 return None
41             state = simplejson.loads(params['state'])
42             token = state.get('t')
43             oauth_uid = validation['user_id']
44             email = validation.get('email', 'provider_%d_user_%d' % (provider, oauth_uid))
45             name = validation.get('name', email)
46             values = {
47                 'name': name,
48                 'login': email,
49                 'email': email,
50                 'oauth_provider_id': provider,
51                 'oauth_uid': oauth_uid,
52                 'oauth_access_token': params['access_token'],
53                 'active': True,
54             }
55             _, login, _ = self.signup(cr, uid, values, token, context=context)
56
57         return login