Skip to content

Commit 758437c

Browse files
committed
sql: now works
1 parent ab95ee1 commit 758437c

4 files changed

Lines changed: 80 additions & 0 deletions

File tree

phpbb/auth/__init__.py

Whitespace-only changes.

phpbb/auth/auth_db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from phpbb.auth.sql import get_user_row
2424
from phpbb.utf.utf_tools import utf8_clean_string
2525
from phpbb.functions import phpbb_check_hash
26+
from phpbb.constants import USER_INACTIVE, USER_IGNORE
2627

2728
def login_db(username=None, password=None):
2829
if not username:

phpbb/auth/sql.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# encoding: utf-8
2+
# vim: shiftwidth=4 expandtab
3+
#
4+
# phpbb-python © Copyright 2010 Santtu Pajukanta
5+
# http://pajukanta.fi
6+
#
7+
# phpBB3 © Copyright 2000, 2002, 2005, 2007 phpBB Group
8+
# http://www.phpbb.com
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, version 2 of the License.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
21+
#
22+
23+
DEFAULT_PARAM_STYLE = '%s'
24+
DEFAULT_USERS_TABLE = 'phpbb_users'
25+
26+
USER_ROW_FIELDS = [
27+
'user_id',
28+
'username',
29+
'user_password',
30+
'user_passchg',
31+
'user_pass_convert',
32+
'user_email',
33+
'user_type',
34+
'user_login_attempts'
35+
]
36+
37+
GET_USER_ROW_SQL = 'SELECT {0} FROM {1} WHERE username_clean = {2}'
38+
39+
class GetUserRow(object):
40+
def __init__(self, *args, **kwargs):
41+
if args or kwargs:
42+
self.setup(*args, **kwargs)
43+
44+
def setup(self, conn, param_style=DEFAULT_PARAM_STYLE, users_table=DEFAULT_USERS_TABLE):
45+
self.conn = conn
46+
self.sql = GET_USER_ROW_SQL.format(", ".join(USER_ROW_FIELDS), users_table, param_style)
47+
48+
def __call__(self, username_clean):
49+
c = self.conn.cursor()
50+
c.execute(self.sql, [username_clean,])
51+
52+
return dict(zip(USER_ROW_FIELDS, c.fetchone()))
53+
54+
get_user_row = GetUserRow()
55+
setup = get_user_row.setup

phpbb/constants.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# encoding: utf-8
2+
# vim: shiftwidth=4 expandtab
3+
#
4+
# phpbb-python © Copyright 2010 Santtu Pajukanta
5+
# http://pajukanta.fi
6+
#
7+
# phpBB3 © Copyright 2000, 2002, 2005, 2007 phpBB Group
8+
# http://www.phpbb.com
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, version 2 of the License.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
21+
#
22+
23+
USER_INACTIVE = 1
24+
USER_IGNORE = 2

0 commit comments

Comments
 (0)