update(self, id, **data) - mansukim1125/JudgeInterface GitHub Wiki
Prototype
update(self, id: int, **data: Dict) -> None
์ค๋ช
id
๋ก ์ง์ ๋๋ ํ ํํ์ data
๋ก ๊ฐฑ์ ํฉ๋๋ค. perform_update(self, id, **data)
์ ๋ค๋ฅธ ์ ์ด๋ผ๋ฉด ์ค๋ฒ๋ผ์ด๋ํ์ฌ data
์ ํน์ field์ ๊ฐ์ ๊ฐ๊ณตํ ์ ์์ต๋๋ค.
์ฌ์ฉ ์
๋ค์์ Users์ ์ค๋ฒ๋ผ์ด๋๋ update์ ๋๋ค.
def update(self, id: int, **data: Dict):
if 'password' in data:
password = data.get('password')
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
data['password'] = hashed_password.decode()
return super().update(id, **data)
์ ์์๋ฅผ ๋ณด๋ฉด ์
๋ ฅ๋ password
๋ฅผ bcrypt
๋ฅผ ํตํด ์ํธํํ ๊ฐ์ผ๋ก ๋ฎ์ด์์ ์ ์ ์์ต๋๋ค.