本文整理汇总了Python中webapp2_extras.appengine.auth.models.User.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_id方法的具体用法?Python User.get_by_id怎么用?Python User.get_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webapp2_extras.appengine.auth.models.User
的用法示例。
在下文中一共展示了User.get_by_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_address
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def get_user_address(self):
user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
if user:
if user.address:
return user.address.address_from
else:
return ''
示例2: login
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def login( self ):
login = self.request.get( 'login', None );
password = self.request.get( 'password', None );
logging.info( "login=%s password=%s" % (login,password) );
# パラメータチェック
if (login is None) or (password is None):
out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="login and password required") };
logging.error( "login and password required" );
self.response.out.write( json.encode(out) )
return
# ログインしようとしているユーザーがメアドを verify 済みかチェック
auth_id = "own:"+ login
m = self.user_model
q = m.query( m.auth_ids==auth_id, m.verified==True )
result = q.get();
if result is None:
out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="ユーザーが存在しないか、メールアドレス認証が完了していません") };
logging.error( "ユーザーが存在しないか、メールアドレス認証が完了していません" );
self.response.out.write( json.encode(out) )
return
user = None
userInfo = self.auth.get_user_by_password( "own:"+ login, password, True, True, True )
# 2013/01/06 以前のバージョンは頭に「own:」がついてなかったので、それにも対応。
if userInfo is None:
logging.info( "2013/01/06 以前のバージョン方式でログインします" );
userInfo = self.auth.get_user_by_password( login, password, True, True, True )
if userInfo is None:
# ログイン失敗
logging.error( "Invalid email/username or password." );
out = {
"meta": functions.createMetaData(
status="fail", code=401, cc_code=1000, message="Invalid email/username or password."
),
};
self.response.out.write( json.encode(out) )
return
# ログイン成功
user = User.get_by_id( userInfo["user_id"] )
sessionId = self.serialize_user_token( auth_info=userInfo )
out = {
"meta": {
"status": "ok",
"code": 200,
"method_name": "loginUser",
"session_id": sessionId,
},
"response":{
"users": [
user.toDict( full=True ),
],
},
};
self.response.out.write( json.encode(out) )
示例3: get_group_users
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def get_group_users(cls, group):
users = []
entries = cls.query().filter(cls.group == group, cls.active == True).fetch()
for entry in entries:
stuff = entry.member
user = User.get_by_id(entry.member.id())
users.append(user)
return users
示例4: post
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def post(self,userid):
print userid
url = images.get_serving_url(self.get_uploads()[0].key())
user = User.get_by_id(int(userid))
print user
user.img = url;
user.put();
self.response.write(resp.success())
示例5: getCurrentUser
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def getCurrentUser( cls ):
logging.error( "現在 getCurrentUser にはバグがあります" )
if cls.userCache=="notInitialized":
myAuth = auth.get_auth()
userInfo = myAuth.get_user_by_session()
if userInfo:
cls.userCache = User.get_by_id( userInfo["user_id"] )
else:
cls.userCache = None
return cls.userCache
示例6: post
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def post(self, token):
if self.form.validate():
token = User.token_model.query(User.token_model.token == token).get()
# test current password
user = User.get_by_id(int(token.user))
if token and user:
user.password = security.generate_password_hash(self.form.password.data, length=12)
user.put()
# Delete token
token.key.delete()
# Login User
self.auth.get_user_by_password(user.auth_ids[0], self.form.password.data)
self.add_message('Password changed successfully', 'success')
return self.redirect_to('profile-show', id=user.key.id())
self.add_message('Please correct the form errors.', 'error')
return self.get(token)
示例7: get_user_phone
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def get_user_phone(self):
user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
if user:
return user.phone
else:
return ''
示例8: get_user_lastname
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def get_user_lastname(self):
user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
if user:
return user.last_name
else:
return ''
示例9: get_user_email
# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
def get_user_email(self):
user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
if user:
return user.email
else:
return ''