As administrator I want to create another users from the iOS app. In my system I would like users to be created via my admin panel.
I have switched public permission to authenticated for User class:
When just public checkmark were selected I was able to create new user in database with this code:
func createUser(with params: [String : Any], completion: @escaping (Result<User?, NSError>) -> ()) {
let pfUser = PFUser()
pfUser.username = params["username"] as? String
pfUser.password = params["password"] as? String
pfUser.email = params["email"] as? String
pfUser["firstname"] = params["firstname"] as? String
pfUser["lastname"] = params["lastname"] as? String
let imageFile = PFFileObject(name:"image.jpg", data:params["avatar"] as! Data)
pfUser["avatar"] = imageFile
pfUser.signUpInBackground { (succeeded, error) in
if let error = error {
print(error)
completion(.failure(error as NSError))
} else {
print("User created successfully")
let user = User()
user.setPFUser(user: pfUser)
completion(.success(user))
}
}
}
But now I am getting error for authenticated class level permission Permission denied, user needs to be authenticated.
:
Is there any solution to do it? Maybe I can inject auth token or smth like this which I user for current admin user which creates another one at the moment.