Skip to content

Commit

Permalink
表结构修改
Browse files Browse the repository at this point in the history
  • Loading branch information
mailgyc committed Jan 18, 2019
1 parent a3d90eb commit fa7f0be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions handlers/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ async def post(self):
password = self.get_query_params('password')
password = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt())

uid = await self.db.insert('INSERT INTO account (email, username, password) VALUES (%s, %s, %s)',
email, username, password)
uid = await self.db.insert('INSERT INTO account (email, username, password, ip_addr) VALUES (%s, %s, %s, %s)',
email, username, password, self.request.remote_ip)
self.set_current_user(uid, username)
self.set_header('Content-Type', 'application/json')
response = {
Expand Down
6 changes: 3 additions & 3 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ CREATE DATABASE IF NOT EXISTS ddz DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_genera

CREATE TABLE IF NOT EXISTS ddz.account (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(20) NOT NULL UNIQUE,
username VARCHAR(10) NOT NULL,
email VARCHAR(40) NOT NULL UNIQUE,
username VARCHAR(40) NOT NULL,
password VARCHAR(100) NOT NULL,
coin INT DEFAULT 4000,
ip_addr VARCHAR(40) NOT NULL,
created_date DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_date DATETIME ON UPDATE CURRENT_TIMESTAMP
);
Expand Down
1 change: 1 addition & 0 deletions settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'template_path': TEMPLATE_ROOT,
'xsrf_cookies': True,
'cookie_secret': 'fiDSpuZ7QFe8fm0XP9Jb7ZIPNsOegkHYtgKSd4I83Hs=',
'xheaders': True,
'debug': options.debug,
}

Expand Down

0 comments on commit fa7f0be

Please sign in to comment.