{"_id":"56c41a86c4796b0d007ef03e","version":{"_id":"56bc8e689afb8b0d00d62dd2","project":"56bc8e679afb8b0d00d62dcf","__v":18,"createdAt":"2016-02-11T13:36:40.146Z","releaseDate":"2016-02-11T13:36:40.146Z","categories":["56bc8e689afb8b0d00d62dd3","56c3c837bc41330d009f25ed","56c3c83e521f350d00d348eb","56c3c8452d97560d00e23cd8","56c3c85234df460d00c2beb8","56c4180d70187b17005f43b4","56c418162d97560d00e23cf6","56c4181cc4796b0d007ef039","56c4182370187b17005f43b5","56c418292e75e01700986052","56c4183328bd680d005e7ac6","56c4183bbb64720d00552b88","56c418414040602b0064cea0","56c4184754b6030d00ec29a1","56c4184c28bd680d005e7ac7","56c4185370187b17005f43b6","56c4185b6063071700500cfc","582a98b6f8c0a0190053d7a5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":6,"category":{"_id":"56c4181cc4796b0d007ef039","version":"56bc8e689afb8b0d00d62dd2","__v":26,"project":"56bc8e679afb8b0d00d62dcf","pages":["56c4192dbc41330d009f25fd","56c4196434df460d00c2bece","56c419814f0aed1700afaba6","56c4198dbc41330d009f25ff","56c419962e75e01700986053","56c4199f54b6030d00ec29a4","56c419a8bb64720d00552b8b","56c419b1bb64720d00552b8d","56c419b92d97560d00e23cf9","56c419c64040602b0064cea3","56c419d4bc41330d009f2601","56c419de70187b17005f43b9","56c419ea6063071700500cfe","56c419fa54b6030d00ec29a6","56c41a096063071700500d00","56c41a1834df460d00c2bed0","56c41a773d30210d00ea8517","56c41a86c4796b0d007ef03e","56c41a904f0aed1700afaba8","56c41a9fbc41330d009f2603","56c41aaa521f350d00d348fe","56c41abb4040602b0064cea5","56c41ad24040602b0064cea7","56c41ade48213b1700af6e28","56c41aeb3d30210d00ea8519","56c41af948213b1700af6e2a"],"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-02-17T06:50:04.339Z","from_sync":false,"order":2,"slug":"users","title":"Users"},"user":"56b98db7bb36440d0001f492","githubsync":"","parentDoc":null,"project":"56bc8e679afb8b0d00d62dcf","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-17T07:00:22.626Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":17,"body":"[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"/users/password\"\n}\n[/block]\nBuddy password reset is a multi-step, fully hosted process that is \"white-label\" for your app. In other words, users are never exposed to Buddy as part of the process.\n\n#### Supporting Password Reset\n\nFor your application to support password reset your app needs to complete three steps:\n\n1.  Collect an email address from the user at account creation.\n\n2.  Implement app functionality that allows the user to request a password reset by providing their username.\n\n3.  Implement app functionality that allows the user to enter the reset code they will receive via email.  The user must enter this code, along with their new password, so Buddy can verify and update their account.\n\n#### The Password Reset Process\n\nTo make the password reset process work the app developer must do the following:\n\n1.  Visit the **Settings** section of the Buddy Developer Dashboard and enter email credentials that Buddy will use as the \"from\" for the password reset emails. When users receive the password reset email it will appear to come from the developer's support account, not from Buddy.\n\n2.  Ensure that the `email` property of each user profile is populated with a valid email for the user. **Note:** An email address is a valid username, however Buddy still needs the `email` property of each account for the password reset feature to work.\n\n3.  When you call the Request Password API you can specify the email subject and body that will be sent to the user.  You will need to add the string `:::at:::ResetCode` in the email body so Buddy can replace it with the user's password reset code. By specifying the subject and body you are able to handle any localization requirements without relying on Buddy.\n\n4. When the user receives their email they must be able to enter the resulting code and a new password into your app. At this point the user's password will be reset.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var options = {\\n\\tuserName: \\\"SuperBuddy\\\",\\n\\tsubject: \\\"Reset Your Password\\\",\\n\\tbody: \\\"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\\\"\\n};\\n\\nBuddy.post('/users/password',\\n\\t\\toptions,\\n\\t\\tfunction(err, result) {\\n\\t\\t\\t \\n\\t\\t\\tif (result.success) {\\n\\t\\t\\t\\t// Do something with the result!\\n\\t\\t\\t} else { \\n\\t\\t\\t\\t// Otherwise log the error\\n\\t\\t\\t\\tconsole.log(err); \\n\\t\\t\\t} \\n\\t\\t}\\n\\t);\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"NSDictionary *params = @{\\n\\t\\t\\[email protected]\\\"userName\\\": @\\\"SuperBuddy\\\",\\n\\t\\t\\[email protected]\\\"subject\\\": @\\\"Reset Your Password\\\",\\n\\t\\t\\[email protected]\\\"body\\\": @\\\"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\\\"\\n\\t\\t};\\n\\n[Buddy POST:@\\\"/users/password\\\" parameters:params class:[NSNumber class] callback:^(id obj, NSError *error) {\\n\\t// Your callback code here\\n}];\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS\"\n    },\n    {\n      \"code\": \"Map<String, Object> parameters = new HashMap<String, Object>();\\nparameters.put(\\\"userName\\\", \\\"SuperBuddy\\\");\\nparameters.put(\\\"subject\\\", \\\"Reset Your Password\\\");\\nparameters.put(\\\"body\\\", \\\"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\\\");\\n\\nBuddy.<Boolean>put(\\\"/users/password\\\", parameters, new BuddyCallback<Boolean>(Boolean.class) {\\n\\[email protected]\\n\\tpublic void completed(BuddyResult<Boolean> result) {\\n\\t\\t// Your callback code here\\n\\t}\\n});\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"var options = new {\\n\\t\\t\\tuserName = \\\"SuperBuddy\\\",\\n\\t\\t\\tsubject = \\\"Reset Your Password\\\",\\n\\t\\t\\tbody = \\\"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\\\"\\n\\t\\t};\\n\\nvar result = await Buddy.PostAsync<bool>(\\\"/users/password\\\", options);\",\n      \"language\": \"csharp\",\n      \"name\": \".NET\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n###Body Parameters\n\nThese parameters should be specified as part of the request body.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"userName\",\n    \"1-0\": \"subject\",\n    \"2-0\": \"body\",\n    \"0-1\": \"A username to identify the user's account. The value must be unique for the application's user base (i.e. duplicate usernames are prohibited across the same application).\",\n    \"1-1\": \"Subject of the email to send to the user\",\n    \"2-1\": \"Body of the email to send to the user.\",\n    \"0-2\": \"string\",\n    \"1-2\": \"string\",\n    \"2-2\": \"string\",\n    \"0-3\": \"Optional\",\n    \"1-3\": \"Required\",\n    \"2-3\": \"Required\"\n  },\n  \"cols\": 4,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"status\\\": 200,\\n  \\\"request_id\\\": \\\"5498a33892e2b004d4094159\\\",\\n  \\\"success\\\": true\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]","excerpt":"","slug":"request-password-reset","type":"basic","title":"Request Password Reset"}

Request Password Reset


[block:api-header] { "type": "post", "title": "/users/password" } [/block] Buddy password reset is a multi-step, fully hosted process that is "white-label" for your app. In other words, users are never exposed to Buddy as part of the process. #### Supporting Password Reset For your application to support password reset your app needs to complete three steps: 1. Collect an email address from the user at account creation. 2. Implement app functionality that allows the user to request a password reset by providing their username. 3. Implement app functionality that allows the user to enter the reset code they will receive via email. The user must enter this code, along with their new password, so Buddy can verify and update their account. #### The Password Reset Process To make the password reset process work the app developer must do the following: 1. Visit the **Settings** section of the Buddy Developer Dashboard and enter email credentials that Buddy will use as the "from" for the password reset emails. When users receive the password reset email it will appear to come from the developer's support account, not from Buddy. 2. Ensure that the `email` property of each user profile is populated with a valid email for the user. **Note:** An email address is a valid username, however Buddy still needs the `email` property of each account for the password reset feature to work. 3. When you call the Request Password API you can specify the email subject and body that will be sent to the user. You will need to add the string `@ResetCode` in the email body so Buddy can replace it with the user's password reset code. By specifying the subject and body you are able to handle any localization requirements without relying on Buddy. 4. When the user receives their email they must be able to enter the resulting code and a new password into your app. At this point the user's password will be reset. [block:code] { "codes": [ { "code": "var options = {\n\tuserName: \"SuperBuddy\",\n\tsubject: \"Reset Your Password\",\n\tbody: \"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\"\n};\n\nBuddy.post('/users/password',\n\t\toptions,\n\t\tfunction(err, result) {\n\t\t\t \n\t\t\tif (result.success) {\n\t\t\t\t// Do something with the result!\n\t\t\t} else { \n\t\t\t\t// Otherwise log the error\n\t\t\t\tconsole.log(err); \n\t\t\t} \n\t\t}\n\t);", "language": "javascript" }, { "code": "NSDictionary *params = @{\n\t\t\[email protected]\"userName\": @\"SuperBuddy\",\n\t\t\[email protected]\"subject\": @\"Reset Your Password\",\n\t\t\[email protected]\"body\": @\"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\"\n\t\t};\n\n[Buddy POST:@\"/users/password\" parameters:params class:[NSNumber class] callback:^(id obj, NSError *error) {\n\t// Your callback code here\n}];", "language": "objectivec", "name": "iOS" }, { "code": "Map<String, Object> parameters = new HashMap<String, Object>();\nparameters.put(\"userName\", \"SuperBuddy\");\nparameters.put(\"subject\", \"Reset Your Password\");\nparameters.put(\"body\", \"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\");\n\nBuddy.<Boolean>put(\"/users/password\", parameters, new BuddyCallback<Boolean>(Boolean.class) {\n\[email protected]\n\tpublic void completed(BuddyResult<Boolean> result) {\n\t\t// Your callback code here\n\t}\n});", "language": "java", "name": "Android" }, { "code": "var options = new {\n\t\t\tuserName = \"SuperBuddy\",\n\t\t\tsubject = \"Reset Your Password\",\n\t\t\tbody = \"It looks like your password needs to be reset! Use this code to reset your password: @ResetCode\"\n\t\t};\n\nvar result = await Buddy.PostAsync<bool>(\"/users/password\", options);", "language": "csharp", "name": ".NET" } ], "sidebar": true } [/block] ###Body Parameters These parameters should be specified as part of the request body. [block:parameters] { "data": { "0-0": "userName", "1-0": "subject", "2-0": "body", "0-1": "A username to identify the user's account. The value must be unique for the application's user base (i.e. duplicate usernames are prohibited across the same application).", "1-1": "Subject of the email to send to the user", "2-1": "Body of the email to send to the user.", "0-2": "string", "1-2": "string", "2-2": "string", "0-3": "Optional", "1-3": "Required", "2-3": "Required" }, "cols": 4, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "{\n \"status\": 200,\n \"request_id\": \"5498a33892e2b004d4094159\",\n \"success\": true\n}", "language": "json", "name": "Response" } ], "sidebar": true } [/block]