Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

Hi im trying to allow users to reset their passwords using my API. So I followed the exact step which the casdoor client does, i.e

  1. Get user details using /api/get-email-and-phone
  2. Send OTP using /api/send-verification-code
  3. Update the password using /api/set-password

However I am getting following error when trying to call /set-password

  "data": {
    "status": "error",
    "msg": "Missing parameter",
    "sub": "",
    "name": "",
    "data": null,
    "data2": null
  }

When I check the code I realized i need to set the session according to following code from set-password handler

if code != c.GetSession("verifiedCode") {
  c.ResponseError(c.T("general:Missing parameter")) <-- fails here
  return
}


So I tried to add a session manually using the API, ( This was added before sending the otp and session Id was also used for sending otp )

        const user = await this.getEmailAndPhone(mobileOrEmail, ''); // call /api/get-email-and-phone
        sessionId = nanoid();
        const session = await this.casdoorClient.sdk.addSession({
          owner: this.casdoorClient.casdoorConfig.orgName,
          name: user.name,
          application: this.casdoorClient.casdoorConfig.appName,
          createdTime: new Date().toISOString(),
          sessionId: [sessionId],
        })

Then I used the sessionId for subsequent requests

    const res = await this.casdoorClient.http.post('/set-password', formData, {
      headers: {
        'Cookie': `casdoor_session=${sessionId}`,
      }
    });

However I am still getting the same error, Is there something wrong im doing here ?

Thanks

Hi, Is there a way to assign a default group to newly sign in user ? Currently I am doing something like this,

    const res = await this.casdoorService.createUser({
      email: data.email,
      name: data.username,
      password: ***,
      groups: this.dynamicConfig.defaultGroups,
    })

Here I assign the groups when creating the user.

However if a user choose 3rd party oauth service, then casdoor it self creates the user. So Im wondering if there's any way to configure the default groups for any new user without writing any code ?

My bad. this was supposed be a string template for the go code. I thought it was about the Twillio template id.

Possible improvement,

Make Template Code field required

Or,

Not to format the code if c.template is empty: https://github.com/casdoor/go-sms-sender/blob/master/twilio.go#L50

Do you want me to add the pull req ? Probably will need to add it to the other provider files as well.

image.png

Hi all. I am pretty new to casdoor and just integrated Twillio provider. It is all working but the message got some symbols. Does anyone know how to fix this ?

Thanks

image.png