yekonga-server
Version:
Yekonga Server
57 lines (51 loc) • 1.9 kB
JavaScript
// @ts-nocheck
/*global Yekonga, serverLibrary */
const resolvers = {
Profile: {
profileUrl: async function(parent, params, context) {
var image = `//${Yekonga.Config.domain}/img/avatar-placeholder.jpg`;
return image;
},
},
Query: {
_profile: async function(parent, params, context) {
const Auth = Yekonga.Auth;
return {
token: Yekonga.Helper.getToken(username),
firstName: 'Super',
lastName: 'Admin',
email: (Yekonga.Config.mail && Yekonga.Config.mail.stmp) ? Yekonga.Config.mail.stmp.from : null,
phone: null,
role: 1,
isAdmin: true,
userId: "admin",
};
},
},
Mutation: {
_login: async function(_, params, context) {
const { input } = params;
var body = input;
var username = body.username;
var password = body.password;
if (Yekonga.Config.adminCredential) {
if (
Yekonga.Config.adminCredential.username == username &&
Yekonga.Config.adminCredential.password == password
) {
return {
token: Yekonga.Helper.getToken(username),
firstName: 'Super',
lastName: 'Admin',
email: (Yekonga.Config.mail && Yekonga.Config.mail.stmp) ? Yekonga.Config.mail.stmp.from : null,
phone: null,
role: 1,
isAdmin: true,
}
}
}
throw new Yekonga.Error.Authentication('Wrong credential');
},
}
}
module.exports = resolvers;