Exemplo n.º 1
0
    def signin_out(self):

        if self.request.get("mode") == 'logout':
            #logoutモードの場合cookieを破棄する
            self.response.delete_cookie('clid')
            self.response.delete_cookie('hash')

        elif self.request.get("mode") == 'login':
            #loginモードの場合cookieを生成する
            user_key = self.makeHash(self.request.get("userID"))
            passwd = self.makeHash(self.request.get('password'))

            pr_user = common_models.user().get_by_id(user_key)
            if pr_user:
                if pr_user.password == passwd:

                    client_id = str(uuid.uuid4())
                    max_age = 60*120
                    pr_list = {'clid':client_id,'hash':user_key}
                    self.put_cookie(pr_list,max_age)
                    self.redirect('/user_screen')
                    return

        self.redirect('/')
        return
Exemplo n.º 2
0
 def get_user(self,uid):
     #ログイン確認&ユーザデータ取得
     if uid == "":
         return False
     else:
         user = common_models.user().get_by_id(uid)
         return user
Exemplo n.º 3
0
    def post(self):
        #post => 登録画面へのデータ送信。入力チェックと確認画面の表示、DBへの登録。
        uid = self.request.get("uid")
        iname = self.request.get("name")
        passstr = self.request.get("password")

        #パスワード,メールアドレスハッシュ生成
        password = self.makeHash(passstr)
        user_key = self.makeHash(uid)

        #ユーザオブジェクト登録
        new_user = common_models.user(id = user_key)
        new_user.mail = uid
        new_user.name = iname
        new_user.password = password
        new_user.put()

        self.redirect('/user_screen')
Exemplo n.º 4
0
    def post(self):
        capital_location = []

        uid = self.request.cookies.get('hash', '')
        nation_name = self.request.get("nation_name")
        capital_name = self.request.get("capital_name")
        capital_location.append(int(self.request.get("locationX")))
        capital_location.append(int(self.request.get("locationY")))

        owner = common_models.user().get_by_id(uid)
        tworld = common_models.World().get_by_id(int(self.request.get("world_key")))

        new_nation = internal_models.Nation()
        new_key = new_nation.creation(owner.key, tworld.key, nation_name)

        first_region = internal_models.Region()
        reg_key = first_region.creation(new_key, capital_name, capital_location)

        new_nation.initialization(reg_key,capital_name)
        owner.join_to_world(tworld.key,new_key)
        tworld.join(new_key)
        self.redirect('/user_screen')
        return