001177e85fe09a3a2fd4c30600a42b92902b3d43,doudizhu/apps/account/views.py,SignupHandler,post,#SignupHandler#,18

Before Change


            "errcode": 0,
            "userinfo": {"uid": uid, "username": username}
        }
        self.write(response)


class LoginHandler(BaseHandler):

After Change


        username = self.get_body_argument("username")
        password = self.get_body_argument("password")
        password_repeat = self.get_body_argument("password_repeat")
        if password != password_repeat:
            self.send_error(403, reason="The password does not match")
            return

        try:
            uid = await self.create_account(username, email, password)
            self.set_secure_cookie("user", json_encode({"uid": uid, "username": username}))
            // token = self.jwt_encode({"uid": uid})
            self.write({"uid": uid, "username": username})
        except pymysql.IntegrityError as e:
            if await self.account_exists(email):
                self.send_error(403, reason="An account with this email address already exists.")
            else:
                raise e

    async def create_account(self, username, email, password) -> int:
        password = await self.run_in_executor(bcrypt.hashpw, password.encode("utf8"), bcrypt.gensalt())
        return await self.db.insert("INSERT INTO account (email, username, password, ip_addr) VALUES (%s,%s,%s,%s)",
                                    email, username, password, self.client_ip)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: mailgyc/doudizhu
Commit Name: 001177e85fe09a3a2fd4c30600a42b92902b3d43
Time: 2019-09-30
Author: gaoyc@outlook.com
File Name: doudizhu/apps/account/views.py
Class Name: SignupHandler
Method Name: post


Project Name: maciejkula/spotlight
Commit Name: eef158f03c4ec9bf872a3e358d62a1fd21a73c35
Time: 2017-07-13
Author: maciej.kula@gmail.com
File Name: examples/movielens_cnn.py
Class Name:
Method Name:


Project Name: probcomp/bayeslite
Commit Name: 0ae9073fb7b144b8d5793f395f2e3240581eb999
Time: 2016-06-29
Author: riastradh+probcomp@csail.mit.edu
File Name: src/compiler.py
Class Name:
Method Name: compile_simulate


Project Name: probcomp/bayeslite
Commit Name: 0ae9073fb7b144b8d5793f395f2e3240581eb999
Time: 2016-06-29
Author: riastradh+probcomp@csail.mit.edu
File Name: src/bql.py
Class Name:
Method Name: execute_phrase