diff --git a/db/models/profile.js b/db/models/profile.js
index e0e726d..5724a31 100644
--- a/db/models/profile.js
+++ b/db/models/profile.js
@@ -10,9 +10,9 @@ var profileSchema = new Schema({
fade: { type: Boolean, default: false },
gorge: { type: Boolean, default: false },
onos: { type: Boolean, default: false },
- commander: { type: Boolean, default: false },
- enslo: { type: Number, default: null }
+ commander: { type: Boolean, default: false }
},
+ enslo: { type: Number, default: null },
division: { type: String, default: null }
});
diff --git a/lib/react/gather.jsx b/lib/react/gather.jsx
index 8095dfa..5984ea8 100644
--- a/lib/react/gather.jsx
+++ b/lib/react/gather.jsx
@@ -633,15 +633,22 @@ var Gatherers = React.createClass({
alt={gatherer.user.country} />);
};
- var division = ({gatherer.user.ability.division});
+ if (gatherer.user.profile.division) {
+ var division = ({gatherer.user.profile.division});
+ }
+
+ var abilities = [];
+ for (let attr in gatherer.user.profile.abilities) {
+ if (gatherer.user.profile.abilities[attr]) abilities.push(_.capitalize(attr));
+ }
var lifeform = (
- gatherer.user.ability.lifeforms.map(lifeform => {
+ abilities.map(lifeform => {
return ({lifeform});
})
);
- var team;
+ var team;
if (gatherer.user.team) {
team = ({gatherer.user.team.name});
}
diff --git a/lib/user/user.js b/lib/user/user.js
index d234b62..54b50d8 100644
--- a/lib/user/user.js
+++ b/lib/user/user.js
@@ -30,11 +30,6 @@ function User (user) {
nickname: null
};
}
- this.ability = {
- division: "Div " + (Math.floor(Math.random() * 4) + 1),
- lifeforms: [["Lerk", "Onos", "Fade"][Math.floor(Math.random() * 3)]],
- commander: true
- }
this.profile = null;
}
@@ -44,11 +39,11 @@ User.find = (id, callback) => {
}, (error, response, body) => {
if (error) return callback(error);
if (response.statusCode !== 200) return callback(new Error("Unable to auth user against API"));
- let u = new User(body);
- Profile.findOrCreate(u, function (error, profile) {
+ let user = new User(body);
+ Profile.findOrCreate(user, function (error, profile) {
if (error) return callback(error);
- u.profile = profile;
- return callback(null, u);
+ user.profile = profile.toJson();
+ return callback(null, user);
});
});
};
diff --git a/spec/profile.js b/spec/profile.js
index 34425b6..1b6f1d3 100644
--- a/spec/profile.js
+++ b/spec/profile.js
@@ -23,7 +23,7 @@ describe("Profile model", () => {
assert.isFalse(result.abilities.fade);
assert.isFalse(result.abilities.onos);
assert.isFalse(result.abilities.commander);
- assert.isNull(result.abilities.enslo);
+ assert.isNull(result.enslo);
assert.isNull(result.division);
done();
});