# Path: apis/verification.py
# class CurrentAccount(object):
# def get_authorization(request):
# def verify_client(client_id, secret):
# def verify_request(request):
# def verify_password(username, password):
# def get_wxapp_userinfo(encrypted_data, iv, code):
# def verify_wxapp(encrypted_data, iv, code):
# def create_token(request):
# def verify_basic_token(token):
# def verify_jwt_token(token):
# 
# Path: apis/exception.py
# class NotFound(MetisException):
#     pass
# 
# Path: apis/models/oauth.py
# class Account(Document):
# 
#     '''
#     帐号
#     :param _id: account ID
#     :param username: 用户ID
#     :param created_time: 创建时间
#     :param password: 密码
#     :param authentications: 认证信息 {'wxapp': 'openid', 'mobile': 'mobile_num'}
#     :param status: 状态(active|发布|forbidden)
#     '''
# 
#     meta = {
#         'collection': 'account',
#         'indexes': [
#             '$username',  # text index
#         ]
#     }
# 
#     id = ObjectIdField(primary_key=True, required=True)
#     nickname = StringField(required=True)
#     avatar = StringField(required=True)
#     username = StringField()
#     password = StringField()
#     authentications = EmbeddedDocumentField(Authentications)
#     created_time = DateTimeField(default=datetime.utcnow())
#     updated_time = DateTimeField()
# 
#     @classmethod
#     def get_by_wxapp(cls, openid):
#         account = cls.objects(authentications__wxapp=openid).first()
#         return account


from apis.verification import current_account
from apis.exception import NotFound
from apis.models.oauth import Account
from . import Resource
# -*- coding: utf-8 -*-



class AccountsSelf(Resource):

    async def get(self, request):
        if not current_account.id:
            raise NotFound('account_not_found')

# Path: apis/verification.py
# class CurrentAccount(object):
# def get_authorization(request):
# def verify_client(client_id, secret):
# def verify_request(request):
# def verify_password(username, password):
# def get_wxapp_userinfo(encrypted_data, iv, code):
# def verify_wxapp(encrypted_data, iv, code):
# def create_token(request):
# def verify_basic_token(token):
# def verify_jwt_token(token):
# 
# Path: apis/exception.py
# class NotFound(MetisException):
#     pass
# 
# Path: apis/models/oauth.py
# class Account(Document):
# 
#     '''
#     帐号
#     :param _id: account ID
#     :param username: 用户ID
#     :param created_time: 创建时间
#     :param password: 密码
#     :param authentications: 认证信息 {'wxapp': 'openid', 'mobile': 'mobile_num'}
#     :param status: 状态(active|发布|forbidden)
#     '''
# 
#     meta = {
#         'collection': 'account',
#         'indexes': [
#             '$username',  # text index
#         ]
#     }
# 
#     id = ObjectIdField(primary_key=True, required=True)
#     nickname = StringField(required=True)
#     avatar = StringField(required=True)
#     username = StringField()
#     password = StringField()
#     authentications = EmbeddedDocumentField(Authentications)
#     created_time = DateTimeField(default=datetime.utcnow())
#     updated_time = DateTimeField()
# 
#     @classmethod
#     def get_by_wxapp(cls, openid):
#         account = cls.objects(authentications__wxapp=openid).first()
#         return account


# Path: apis/auth/api/accounts_self.py
from apis.verification import current_account
from apis.exception import NotFound
from apis.models.oauth import Account
from . import Resource

# -*- coding: utf-8 -*-



class AccountsSelf(Resource):

    async def get(self, request):
        if not current_account.id:
            raise NotFound('account_not_found')

        account = Account.objects(id=current_account.id).first()