Skip to content

Instantly share code, notes, and snippets.

@openqubit
Last active June 13, 2016 22:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save openqubit/12ebcce5f91228e2a295b8ff0327512b to your computer and use it in GitHub Desktop.
Save openqubit/12ebcce5f91228e2a295b8ff0327512b to your computer and use it in GitHub Desktop.
Creating A User Using Autoform
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;
}
}
})
{{ #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 }}
'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);
},
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