Last active
June 13, 2016 22:40
-
-
Save openqubit/12ebcce5f91228e2a295b8ff0327512b to your computer and use it in GitHub Desktop.
Creating A User Using Autoform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AutoForm.hooks({ | |
usercreation:{ | |
onSubmit: function (doc) { | |
this.event.preventDefault(); | |
//Schema.User.clean(doc); | |
// console.log("People doc with auto values", doc); | |
// var schoolname = profile.schoolname; | |
// var schooldescription = doc.schooldescription; | |
// var schoollocation = doc.schoollocation.value; | |
// var schoollogo = doc.schoollogo; | |
// var schooltelephonenumber = doc.schooltelephonenumber; | |
//var sn = sn.replace(/\s/g, ''); | |
// var post = { | |
// input_sn: schoolname, | |
// input_sd: schooldescription, | |
// input_sl: schoollocation, | |
// input_slogo: schoollogo, | |
// input_stn: schooltelephonenumber | |
// }; | |
Meteor.call('usercreation', doc); | |
this.done(); | |
return false; | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ #autoForm schema="Schema.User" class="uc" id="usercreation" collection ="Meteor.users" type="method" validation="none" meteormethod="usercreation" }} | |
<fieldset> | |
<legend>Create an account</legend> | |
{{> afQuickField name='emails' label='Email' }} | |
{{> afQuickField name='password' type="password" label='Password' }} | |
{{> afQuickField name='profile.schoolname' label='School Name' }} | |
{{> afQuickField name='profile.schooldescription' label='School Description' }} | |
{{> afQuickField name='profile.schoollocation' label='Location'}} | |
{{> afQuickField name='profile.schoollogo' label='School Logo' }} | |
{{> afQuickField name='profile.schooltelephonenumber' label='School Telephone Number' }} | |
</fieldset> | |
<input type="submit"> | |
{{ /autoForm }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'usercreation': function(doc){ | |
console.log("Someone tell Wyatt we're here too!"); | |
var em = doc.emails[0].address; | |
console.log(em); | |
Accounts.createUser({ | |
email: em, | |
password: doc.password, | |
profile: { | |
schoolname: doc.profile.schoolname, | |
schooldescription: doc.profile.schooldescription, | |
schoollocation: doc.profile.schoollocation, | |
schoollogo: doc.profile.schoollogo, | |
schooltelephonenumber: doc.profile.schooltelephonenumber | |
} | |
}); | |
//Accounts.createUser(doc); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schema = {}; | |
Schema.UserProfile = new SimpleSchema({ | |
schoolname: { | |
label: "School Name", | |
optional: false, | |
type: String | |
}, | |
schooldescription: { | |
label: "School Description", | |
optional: false, | |
type: String | |
}, | |
schoollocation : { | |
label: "School Location", | |
optional: false, | |
type: String | |
}, | |
schoollogo : { | |
label: "School Logo", | |
optional: false, | |
type: String | |
}, | |
schooltelephonenumber: { | |
label: "School Telephone Number", | |
optional: false, | |
type: String | |
} | |
}); | |
Schema.User = new SimpleSchema({ | |
emails: { | |
type: [Object] | |
}, | |
"emails.$.address": { | |
type: String, | |
optional: true | |
}, | |
"emails.$.verified": { | |
type: Boolean | |
}, | |
password: { | |
type: String, | |
optional: true | |
}, | |
createdAt: { | |
type: Date, | |
optional: true | |
}, | |
profile: { | |
type: Schema.UserProfile, | |
optional: false | |
}, | |
services: { | |
type: Object, | |
optional: true, | |
blackbox: true | |
} | |
}); | |
Meteor.users.attachSchema(Schema.User); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment