Skip to content

Commit

Permalink
Merge pull request #8 from tobias-g1/develop
Browse files Browse the repository at this point in the history
Add additional profile options
  • Loading branch information
surpassinggoogle committed Mar 30, 2019
2 parents 89c848f + c418954 commit 9afa6b9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/controllers/profile.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,29 @@ exports.set_profile = (req, res) => {
// Edit Profile

exports.edit_profile = (req, res) => {
let {username, name, expertise, test, about, profilePic, coverPic, languages, social, vacation, location, gender} = req.body
console.log('from frontend', {test, vacation})
let {username, name, expertise, test, about, profilePic, coverPic, languages, social, vacation, location, gender, skillsAndHobbies, learning, socialReach, helpWith, portfolio} = req.body
if (req.user === username) {
User.findOne({username}, (err, userData) => {
if (!err) {
if (userData) {
console.log('fetched userData::', stringify(userData))
if (name) {
userData.name = name
}
if (skillsAndHobbies) {
userData.skillsAndHobbies = skillsAndHobbies
}
if (portfolio) {
userData.portfolio = portfolio
}
if (helpWith) {
userData.helpWith = helpWith
}
if (socialReach) {
userData.socialReach = socialReach
}
if (learning) {
userData.learning = learning
}
if (expertise) {
userData.expertise = expertise
}
Expand Down Expand Up @@ -176,7 +189,6 @@ exports.edit_profile = (req, res) => {
userData.vacation = vacation
userData.save((err, modifiedUserData) => {
if (!err) {
console.log('modified user Data::', stringify(modifiedUserData))
res.send(modifiedUserData)
} else {
handleErr(err, res, 'there was an error modifying your profile')
Expand Down Expand Up @@ -210,7 +222,6 @@ exports.verify_user = (req, res) => {
if (token) {
axios.get(`https://steemconnect.com/api/me?access_token=${token}`).then(response => {
let responseData = response.data
// console.log((responseData))
res.send(responseData)
}).catch(err => {
if (err.response) {
Expand Down Expand Up @@ -250,14 +261,18 @@ exports.get_profile = (req, res) => {
steem.api.getAccounts([username], function (err, authorArray) {
let author = authorArray[0]
if (!err) {
if (Object.keys(profile).length < 1) {
if (Object.keys(profile).length === 0) {
let apiProfile = {}
if (JSON.parse(author.json_metadata).profile) {
apiProfile = JSON.parse(author.json_metadata).profile
}
let {profile_image: profilePic, name, about, location, website, cover_image: coverPic, facebook, github, instagram, twitter, discord} = apiProfile
let {profile_image: profilePic, name, about, location, website, cover_image: coverPic, facebook, github, instagram, twitter, discord, skillsAndHobbies, helpWith} = apiProfile
profile = {
username,
skillsAndHobbies: skillsAndHobbies || [],
helpWith: helpWith || [],
socialReach: socialReach || '',
learning: learning || [],
social: {
website: website || '',
facebook: facebook || '',
Expand All @@ -282,6 +297,12 @@ exports.get_profile = (req, res) => {
} else {
profile.steemgigsWitness = false
}
if (!profile.portfolio) {
profile.portfolio = {
description: '',
url: ''
}
}
profile.certifiedUloggerStatus = res.locals.certifiedUloggerStatus || false
res.json(profile)
} else {
Expand Down
20 changes: 20 additions & 0 deletions src/model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ let userSchema = new Schema({
type: Number,
required: false
},
socialReach: {
type: String,
required: false,
},
skillsAndHobbies: {
type: Array,
required: false,
},
portfolio: {
type: Object,
required: false,
},
learning: {
type: Array,
required: false,
},
helpWith: {
type: Array,
required: false,
},
last_login: {
type: Number,
required: false
Expand Down

0 comments on commit 9afa6b9

Please sign in to comment.