0
是否有可能将用户添加到角色,当他们注册?并将它们添加为基本用户?将用户添加到角色,当他们注册
我一直在尝试,现在有一阵子,但似乎无法推测出来。
对于我的注册脚本,我使用下面的代码:
func SignUp() {
let user = PFUser()
user.username = UsernameTextField.text
user.password = PasswordTF.text
user.email = EmailTF.text
user.signUpInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if error == nil {
// Hooray! Let them use the app now.
let alertcontroller = UIAlertController(title: "Russeradar", message: "Din bruker er nå opprettet! Du kan nå logge in" , preferredStyle: UIAlertControllerStyle.Alert)
alertcontroller.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertcontroller,animated: true, completion: nil)
} else {
// Examine the error object and inform the user.
let alertcontroller = UIAlertController(title: "Russeradar", message: "Din bruker kunne ikke opprettes. Prøv på nytt senere!" , preferredStyle: UIAlertControllerStyle.Alert)
alertcontroller.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertcontroller,animated: true, completion: nil)
}
}
}
如果我需要提供更多的信息,让我知道。
Okei,谢谢。我对此很新。我如何定义ACL?而且我不需要将用户保存为用户名吗?就像如果我要说的是,注册用户得到了角色基本用户/用户 –
你是不是想你的用户分手分为两类,管理员用户与普通用户? – MJJLAM
是的,这是正确的 –