import request from '@/utils/request' 

// 登录方法
export function login(username, password) {
    const params = {
        username,
        password
    }
    return request({
        url: '/api/v1/auth/login',
        headers: {
            isToken: false
        },
        method: 'post',
        data: params,
    })
}



// 获取用户详细信息
export function getInfo(userUid) { 
    return request({
        url: `/api/v1/auth/users/${userUid}`,
        method: 'get'
    })
}

// 退出方法
export function logout() {
    return request({
        url: '/api/v1/auth/logout',
        method: 'post'
    })
}

//修改密码
export function changePwd(oldPassword, newPassword) {
    const params = {
        old_password: oldPassword,
        new_password: newPassword
    }
    return request({
        url: '/api/v1/auth/change-password',
        method: 'post',
        data: params
    })
}

//验证密码强度
export function checkPwdStrength(password) {
    const params = {
        password: password
    }
    return request({
        url: '/api/v1/auth/check-password-strength',
        method: 'post',
        data: params
    })
}

// 获取用户头像
export function getAvatarsApi(name) {
    return request({
        url: `/api/v1/avatars/username/${name}/200`,
        method: 'get',
        responseType: 'blob'
      });
}